bug
bug copied to clipboard
Abstract type member instantiation causes illegal cyclic reference compile error
The following code doesn't compile and cause 'illegal cyclic reference' compile error
object IllegalCyclicReference {
trait Problem {
def x: X
// If we uncomment below , we get the compiler error "illegal cyclic reference" ????
// def z = x.z
}
trait Y[S]
trait X {
type S = Z
trait Z extends Y[S]
def z: Z
}
}
See also ScalaFiddle: https://scalafiddle.io/sf/zuBKhBy/5
All major scala compiler (2.10, 2.11, 2.12) versions cause the error except Dotty.
I see the label 'fixed in Dotty' but is it really 'fixed'?
It could well be that my construction is invalid and the none-Dotty compilers are correct...
non-Dotty == scala 2.x.y
That's awkward.
- Moving
ProblembelowXmakes the error go away - So does ascribing
def z: X#S = x.z - But ascribing
def z: X#Z = x.zstill fails
So I guess it depends on the order in which the types are completed.