1 2 3 4 5 6 7 8 9 10 11 12 13
class Inv[T] class Foo { val foo: Inv[this.type] = new Inv[this.type] } object Test { def test: Unit = { val e1 = new Foo val f1: Inv[Foo] = e1.foo // error var e2 = new Foo val f2: Inv[Foo] = e2.foo // error } }