Skip to content

Commit ab65f31

Browse files
committed
Simplify logic for checking local classes inside secondary constructors
1 parent da7356c commit ab65f31

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,8 @@ class Semantic {
265265
def call(meth: Symbol, args: List[ArgInfo], superType: Type, source: Tree): Contextual[Result] =
266266
value.call(meth, args, superType, source) ++ errors
267267

268-
def instantiate(klass: ClassSymbol, ctor: Symbol, args: List[ArgInfo], source: Tree, inside: ClassSymbol): Contextual[Result] =
269-
value.instantiate(klass, ctor, args, source, inside) ++ errors
268+
def instantiate(klass: ClassSymbol, ctor: Symbol, args: List[ArgInfo], source: Tree): Contextual[Result] =
269+
value.instantiate(klass, ctor, args, source) ++ errors
270270
}
271271

272272
/** The state that threads through the interpreter */
@@ -450,7 +450,7 @@ class Semantic {
450450
}
451451

452452
/** Handle a new expression `new p.C` where `p` is abstracted by `value` */
453-
def instantiate(klass: ClassSymbol, ctor: Symbol, args: List[ArgInfo], source: Tree, inside: ClassSymbol): Contextual[Result] = log("instantiating " + klass.show + ", value = " + value + ", args = " + args, printer, res => res.asInstanceOf[Result].show) {
453+
def instantiate(klass: ClassSymbol, ctor: Symbol, args: List[ArgInfo], source: Tree): Contextual[Result] = log("instantiating " + klass.show + ", value = " + value + ", args = " + args, printer, res => res.asInstanceOf[Result].show) {
454454
val trace1 = trace.add(source)
455455
if promoted.isCurrentObjectPromoted then Result(Hot, Nil)
456456
else value match {
@@ -489,15 +489,15 @@ class Semantic {
489489

490490
// Approximate instances of local classes inside secondary constructor as Cold.
491491
// This way, we avoid complicating the domain for Warm unnecessarily
492-
if klass.isContainedIn(inside) && inSecondaryConstructor(klass.owner) then Result(Cold, res.errors)
492+
if inSecondaryConstructor(klass.owner) then Result(Cold, res.errors)
493493
else Result(value, res.errors)
494494

495495
case Fun(body, thisV, klass, env) =>
496496
report.error("unexpected tree in instantiating a function, fun = " + body.show, source)
497497
Result(Hot, Nil)
498498

499499
case RefSet(refs) =>
500-
val resList = refs.map(_.instantiate(klass, ctor, args, source, inside))
500+
val resList = refs.map(_.instantiate(klass, ctor, args, source))
501501
val value2 = resList.map(_.value).join
502502
val errors = resList.flatMap(_.errors)
503503
Result(value2, errors)
@@ -743,7 +743,7 @@ class Semantic {
743743
val trace2 = trace.add(expr)
744744
locally {
745745
given Trace = trace2
746-
(res ++ errors).instantiate(cls, ctor, args, source = expr, inside = klass)
746+
(res ++ errors).instantiate(cls, ctor, args, source = expr)
747747
}
748748

749749
case Call(ref, argss) =>

0 commit comments

Comments
 (0)