-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Reference to type parameter name is ambiguous with inner trait and self-type to outer trait #9844
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
and I can't seem to find a work-around for this to cross-compile 2.13, Dotty |
Here is a work-around (I still think this is a bug) object DetSkipOctree {
sealed trait Leaf [PL]
sealed trait Branch[PL] {
def newLeaf(qIdx: Int): Leaf[PL]
}
}
trait DetSkipOctree[PL]
class Impl[_PL] extends DetSkipOctree[_PL] {
final type Leaf = DetSkipOctree.Leaf[_PL]
protected trait LeftBranchImpl {
this: DetSkipOctree.Branch[_PL] =>
def demoteLeaf(point: _PL, leaf: Leaf): Unit = ???
final def insert(point: _PL): Leaf = newLeaf(1234)
}
} |
The work-around does not really work, as eventually there is a problem between
(here it's |
trait Foo[A]
trait Baz[A] {
trait Bar {
this: Foo[A] =>
def bar(a: A): Unit
}
}
But compiles successfully with Scala 2.13.3. |
@griggt thanks for minimising even further |
Potential workaround: trait Foo[A]
trait Baz[A] {
type Q = A // added type alias
trait Bar {
this: Foo[A] =>
def bar(a: Q): Unit
}
} and for the original code: object DetSkipOctree {
sealed trait Leaf [PL]
sealed trait Branch[PL]
}
trait DetSkipOctree[PL]
class Impl[PL] extends DetSkipOctree[PL] {
final type Leaf = DetSkipOctree.Leaf[PL]
type PLL = PL // added type alias
protected trait LeftBranchImpl {
this: DetSkipOctree.Branch[PL] =>
def demoteLeaf(point: PLL, leaf: Leaf): Unit = ???
}
} Seems to work for both dotty and scalac, for these examples. |
This is the new check #8617 in overdrive. Scala 2 doesn't benefit from the check yet. |
It actually fails with a different error if compiled with a Dotty without #8622 (the fix for #8617) merged. I tried it with both dotty 0.23.0 and 0.28.0-bin-SNAPSHOT-git-333ab8e that I patched to remove the change introduced by 8622. The result is the same in both cases: trait Foo[A]
trait Baz[A] {
trait Bar {
this: Foo[A] =>
def bar(a: A): Unit
}
}
As it differs from Scala 2, what is the expected (documented?) behavior? |
I think all examples should compile. |
Thanks for the minimizations! That was vey helpful in finding the problem, which turned out to be quite fundamental. |
Fix #9844: Exclude private members of wrong classes from findMember
Minimized code
Output
Expectation
It's clear that
PL
unambiguously refers to the same thing. This compiles in 2.13.The text was updated successfully, but these errors were encountered: