Skip to content

Commit 41807c9

Browse files
committed
Skip check for local classes inside constructors
1 parent 98a0977 commit 41807c9

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

compiler/src/dotty/tools/dotc/transform/init/Semantic.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ class Semantic {
896896

897897
def default() = Result(Hot, Nil)
898898

899-
if sym.is(Flags.Param) && sym.owner.isConstructor then
899+
if sym.is(Flags.Param) && sym.owner.isConstructor && sym.isContainedIn(klass) then
900900
// instances of local classes inside secondary constructors cannot
901901
// reach here, as those values are abstracted by Cold instead of Warm.
902902
// This enables us to simplify the domain without sacrificing

tests/init/neg/secondary-ctor4.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class M(x: Int) {
3535
val n: Int = 10
3636
}
3737

38-
new A(new B(new D))
38+
new A(new B(new D)) // error
3939

4040
trait T {
4141
val m: Int = 10
@@ -51,3 +51,7 @@ class M(x: Int) {
5151
}
5252
}
5353
}
54+
55+
class N extends M("hello") {
56+
val msg = "Scala"
57+
}

0 commit comments

Comments
 (0)