-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skip check for local classes in constructors
This is a temporary solution as we don't want to complicate the domain and implementation for a code pattern that is extremely rare.
- Loading branch information
1 parent
b5458f1
commit 98a0977
Showing
3 changed files
with
75 additions
and
13 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,53 @@ | ||
class M(x: Int) { | ||
|
||
def this(s: String) = { | ||
this(s.size) | ||
|
||
class L1(x: Int) { val n: Int = 5 } | ||
|
||
class A(b: B, x: Int) { | ||
println(s.size) | ||
|
||
class L2(x: Int) { val n: Int = 5 } | ||
|
||
def this(b: B) = { | ||
this(b, 5) | ||
println(s.size) | ||
|
||
class Inner() { | ||
println(s.size) | ||
println(b.n) | ||
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 | ||
} | ||
|
||
new A(new B(new D)) | ||
|
||
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) | ||
} | ||
} | ||
} |