@@ -475,22 +475,14 @@ class Semantic {
475
475
476
476
case addr : Addr =>
477
477
given Trace = trace1
478
-
479
478
// widen the outer to finitize addresses
480
479
val outer = addr match
481
480
case Warm (_, _ : Warm , _, _) => Cold
482
481
case _ => addr
483
482
484
483
val value = Warm (klass, outer, ctor, args.map(_.value).widenArgs).ensureExists
485
484
val res = value.call(ctor, args, superType = NoType , source)
486
-
487
- def inSecondaryConstructor (sym : Symbol ): Boolean =
488
- ! sym.isClass && (sym.isConstructor || inSecondaryConstructor(sym.owner))
489
-
490
- // Approximate instances of local classes inside secondary constructor as Cold.
491
- // This way, we avoid complicating the domain for Warm unnecessarily
492
- if inSecondaryConstructor(klass.owner) then Result (Cold , res.errors)
493
- else Result (value, res.errors)
485
+ Result (value, res.errors)
494
486
495
487
case Fun (body, thisV, klass, env) =>
496
488
report.error(" unexpected tree in instantiating a function, fun = " + body.show, source)
@@ -901,7 +893,12 @@ class Semantic {
901
893
// This enables us to simplify the domain without sacrificing
902
894
// expressiveness nor soundess, as local classes inside secondary
903
895
// constructors are uncommon.
904
- Result (env.lookup(sym), Nil )
896
+ if sym.isContainedIn(klass) then
897
+ Result (env.lookup(sym), Nil )
898
+ else
899
+ // We don't know much about secondary constructor parameters in outer scope.
900
+ // It's always safe to approximate them with `Cold`.
901
+ Result (Cold , Nil )
905
902
else
906
903
default()
907
904
0 commit comments