-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Nothing inferred for path dependent type parameter #8991
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
Comments
It looks like we don't handle unstable prefixes like in Scala 2: class Foo {
class A
object A {
implicit val implicitA: A = new A
}
def get(implicit a: A): A = a
}
object Test {
(new Foo).get
} Dotty fails to find the implicit for <synthetic> <stable> <artifact> val stabilizer$1: Foo = new Foo();
stabilizer$1.get(stabilizer$1.A.implicitA)
This sort of makes sense: the type of the parameter is In Dotty, synthetic definitions like this are normally created using a "lifter", see https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/typer/EtaExpansion.scala, perhaps we should add some logic to lift the prefix of an implicit method call when needed (which seems to be at a minimum when the prefix is unstable and the type is a class type). Note that this can be worked around by manually using a stable prefix: def test1 = {
val m = new MacroImpl(???)
m.poly[Int]
} |
We should check in which situations exactly scalac introduces these stabilizer definitions. Note that some of these situations are already handle by skolemization which is much cheaper: 502c7c9 |
My intuition was that signatures always mapped to the JVM signature of a matching overload, but this appears to not be the case, a callsites' arguments should not affect it surely? or if an overload was not found then should this not compile |
Yeah it's a bt confusing: Dotty uses signatures to distinguish between overloads and overrides, so signatures are always computed as seen from some prefix, e.g. in: class Foo[A] {
def foo(x: A): String = "foo"
}
class Bar extends Foo[Int] {
override def foo(x: A): String = "bar"
} There's two definitions for |
Uh oh!
There was an error while loading. Please reload this page.
Minimized code
Output
Expectation
This should compile as it does with Scala 2.13.2
This is also critical to support macro compatibility with macro bundles
The alternative below compiles, but the signature in TASTy for
MacroImpl.poly
ispoly[Signed Signature(List(1, scala.Nothing),Macros$.Universe.Tree)]
, which is incorrectThe text was updated successfully, but these errors were encountered: