Closed
Description
minimized code
object test {
trait B { type X; def mkX(i: Int): B#X }
val b: B = new B { type X = Int; def mkX(i: Int): X = i }
}
Compilation output
-- Error: test.scala:3:39 ------------------------------------------------------
3 | val b: B = new B { type X = Int; def mkX(i: Int): X = i }
| ^
| error overriding method mkX in trait B of type (i: Int): test.B#X;
| method mkX of type (i: Int): X has incompatible type
1 error found
expectation
Should compile. Note that this already compiles:
trait B { type X; def mkX(i: Int): X }
val b: B = new B { type X = Int; def mkX(i: Int): X = i }
implicitly[b.X <:< B#X]
From the outside X
is a subtype of B#X
but inside new B { }
not.
Related issue: #538