-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Implicits#viewExists: return false after typer instead of AssertionError #438
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
Conversation
This way, tpd#applyOverloaded can safely be used after typer. This issue was encoutered while working on value classes, step 3 of SIP-15 contains the following peephole optimization: new C(e) == new C(f) => e == f Which requires us to do overloading resolution.
|
If you're wondering, the assert is triggered in inferImplicit which is called by inferView which is called by viewExists. |
|
Yes, looks like we have to do it this way. LGTM. |
Implicits#viewExists: return false after typer instead of AssertionError
|
Where is the overload resolution? See scala/scala#3497 / SI-8129. We determined that the overloaded nature of |
|
|
|
Oh, that makes sense. An alternative fix might have been to arrange things such that I suppose you could also avoid fully blown overload resolution with something like: scala> def main_==(sym: Symbol) = sym.info.member(nme.EQ).suchThat(_.info.params.head.info.typeSymbol == sym)
main_$eq$eq: (sym: $r.intp.global.Symbol)$r.intp.global.Symbol
scala> main_==(symbolOf[Int]).defString
res12: String = def ==(x: Int): Boolean
scala> main_==(symbolOf[Char]).defString
res13: String = def ==(x: Char): BooleanI only suggest this because in Scala2 we have a dev warning when overload resolution happens post typer, as this has occasionally shown up as a symptom of a bug. It would be nice to have the same sort of clean line in the sand in dotty. |
|
@retronym this commit actually disables implicit search after typer entirely. |
|
@retronym : Maybe, but you still need to check if the underlying type is a value class or not, because you cannot do: scala> main_==(symbolOf[String]).defString
res1: String = <none>And I wanted to use |
|
I don't feel too strongly either way, just wanted to make sure the different possibilities were considered. Here's a fun test that seems to argue in favour of your approach: AFAICT this is as specced, as SIP-15 specifies the synthetic |
Backport "Add inlay hints for by-name parameters" to 3.3 LTS
This way, tpd#applyOverloaded can safely be used after typer. This issue
was encoutered while working on value classes, step 3 of SIP-15 contains
the following peephole optimization:
Which requires us to do overloading resolution.
Review by @odersky .