New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix override return type check #10141
fix override return type check #10141
Conversation
I think it must be fixed in |
Thank you, I'll take a look. |
6f0fbe4
to
d6b109f
Compare
@jxnu-liguobin we've been slow with PR reviews lately, because of the 2.13.10 release and other factors... but I'm trying to get things moving again. mind rebasing this one to resolve the merge conflict? then we can try to find a reviewer. |
The override inference behavior has needed a couple of passes for correctness. The conflict is probably due to those edits. I'm not sure how this issue will interact. In particular, there is also #10198 (which may not stand scrutiny). |
9a12064
to
52db6ec
Compare
I pushed a rebase — the merge conflict seemed easy to resolve. Let's see what CI thinks. |
CI likes it. @som-snytt can I interest you in serving as reviewer here? |
I'm taking a look. I'd like to understand why the
The proposed fix is downstream from there. Edit: something to do with whether the param type is stable. Probably that only matters if the result is a member type
|
I submitted an alternative that attempts to infer or construct the correct The approach in this PR is to keep the type of the RHS, but I'll leave this PR open until I understand the alternatives better. |
@@ -1109,14 +1109,26 @@ trait Namers extends MethodSynthesis { | |||
case _ => sym.isStable && !refersToSymbolLessAccessibleThan(tpe, sym) | |||
} | |||
|
|||
def keepWhenMissResultTypeForSingleton: Option[Type] = { | |||
sym.overrideChain.drop(1).map(_.tpe).headOption.flatMap { | |||
case MethodType(_, rt) if !rt.typeSymbol.isAliasType && rt.isInstanceOf[SingletonType] && tpe <:< rt.dealiasWiden => Some(rt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overrideChain
may be too much; compare computeOverridden
. What is isAliasType
guarding? A test would show it.
I tried the neg test (from the other PR), and this compiles! To review, the overridden type becomes an existential with
Now I see that |
(the other PR being #10334) |
@jxnu-liguobin thank you for pursuing this as far as you did — looks like the baton is passed to Som |
Also thanks for patience and actually taking the first two swings. It's a lot to chew on, and I might have had actionable feedback earlier if I knew what I was doing, or what the compiler is doing. I definitely would not have waded into these waters first. Also the other PR isn't over the finish line. It's not even on the last lap. |
closed scala/bug#12621