The error can be reproduced by compiling the following code:
object ReproducingMyError {
trait MyTrait[X] {
def someFunc: X
}
def f[X] = new MyTrait[X] {
var x: X = _
def someFunc: X = x
}
}
2 error messages were generated. Both point to
def f[X] = new MyTrait[X] {
^
The messages are similar:
Error: Parameter type in structural refinement may not refer to an abstract type defined outside that refinement
Error: Parameter type in structural refinement may not refer to a type member of that refinement
Why is this a compilation error?