forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
29cc844
commit cea9f26
Showing
3 changed files
with
105 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
def foo() = | ||
class L1(x: Int) { val n: Int = 5 } | ||
|
||
class A(b: B, x: Int) { | ||
class L2(x: Int) { val n: Int = 5 } | ||
|
||
def this(b: B) = { | ||
this(b, 5) | ||
class Inner() { | ||
def foo() = println(b.n) | ||
} | ||
Inner().foo() // error: calling method on cold | ||
|
||
val l1 = new L1(3) | ||
println(l1.n) | ||
|
||
val l2 = new L2(3) | ||
println(l2.n) | ||
|
||
(() => new A(b, 3))() // ok | ||
} | ||
} | ||
|
||
class B(val d: D) { | ||
val n: Int = 10 | ||
} | ||
|
||
trait T { | ||
val m: Int = 10 | ||
} | ||
|
||
class C(b: B) extends A(b) with T { | ||
def this(b: B, x: Int) = this(b) | ||
} | ||
|
||
class D { | ||
val b = new B(this) | ||
val c = new C(b, 5) | ||
} |