Skip to content

Commit 8237d68

Browse files
committed
Add test
1 parent fab653e commit 8237d68

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/init/neg/secondary-ctor2.scala

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
class A(b: B, x: Int) {
2+
def this(b: B) = {
3+
this(b, 5)
4+
class Inner() {
5+
def foo() = println(b.n)
6+
}
7+
Inner().foo() // error: calling method on cold
8+
9+
val f = () => new A(b, 3)
10+
f() // ok
11+
}
12+
}
13+
14+
class B(val d: D) {
15+
val n: Int = 10
16+
}
17+
18+
class C(b: B) extends A(b) {
19+
def this(b: B, x: Int) = this(b)
20+
}
21+
22+
class D {
23+
val b = new B(this)
24+
val c = new C(b, 5)
25+
}

0 commit comments

Comments
 (0)