Skip to content

Commit e5cd6fa

Browse files
committed
Lazily use synthetic apply
Otherwise, as the test tests/init/pos/local-warm5.scala shows, we may reach an outer that is cold.
1 parent 1790ef1 commit e5cd6fa

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,13 +625,14 @@ object Semantic {
625625
given Trace = trace1
626626
val cls = target.owner.enclosingClass.asClass
627627
val ddef = target.defTree.asInstanceOf[DefDef]
628+
val argErrors = checkArgs
628629
// normal method call
629-
if isSyntheticApply(meth) then
630+
if argErrors.nonEmpty && isSyntheticApply(meth) then
630631
val klass = meth.owner.companionClass.asClass
631632
instantiate(klass, klass.primaryConstructor, args, source)
632633
else
633634
withEnv(if isLocal then env else Env.empty) {
634-
eval(ddef.rhs, ref, cls, cacheResult = true) ++ checkArgs
635+
eval(ddef.rhs, ref, cls, cacheResult = true) ++ argErrors
635636
}
636637
else if ref.canIgnoreMethodCall(target) then
637638
Result(Hot, Nil)

0 commit comments

Comments
 (0)