Skip to content

Commit 87f1d9c

Browse files
committed
Add test: class fields cannot be used as parent prefix
1 parent 9b087ce commit 87f1d9c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/neg/i5083c.scala

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
class A(a: Int) {
2+
trait X {
3+
def f: Int
4+
val x = a + f // NPE: the outer for `Y` is not yet set
5+
}
6+
7+
trait Y {
8+
val y = a
9+
def f: Int = A.this.a // NPE: the outer for `Y` is not yet set
10+
}
11+
12+
class Z(o: A) extends m.Y { // error
13+
val m = o
14+
}
15+
16+
class B extends Z(new A(4))
17+
}
18+
19+
20+
object Test {
21+
def main(args: Array[String]): Unit = {
22+
val a = new A(3)
23+
new a.B
24+
}
25+
}

0 commit comments

Comments
 (0)