@@ -569,7 +569,26 @@ object Semantic {
569
569
report.error(" unexpected constructor call, meth = " + ctor + " , value = " + value, source)
570
570
Result (Hot , Nil )
571
571
572
- case ref : Ref =>
572
+ case ref : Warm =>
573
+ val trace1 = trace.add(source)
574
+ if ctor.hasSource then
575
+ given Trace = trace1
576
+ val cls = ctor.owner.enclosingClass.asClass
577
+ val ddef = ctor.defTree.asInstanceOf [DefDef ]
578
+ given Env = Env (ddef, args.map(_.value).widenArgs)
579
+ if ctor.isPrimaryConstructor then
580
+ val tpl = cls.defTree.asInstanceOf [TypeDef ].rhs.asInstanceOf [Template ]
581
+ init(tpl, ref, cls)
582
+ else
583
+ val initCall = ddef.rhs match
584
+ case Block (call :: _, _) => call
585
+ case call => call
586
+ eval(initCall, ref, cls)
587
+ end if
588
+ else
589
+ Result (Hot , Nil )
590
+
591
+ case ref : ThisRef =>
573
592
val trace1 = trace.add(source)
574
593
if ctor.hasSource then
575
594
given Trace = trace1
@@ -871,6 +890,7 @@ object Semantic {
871
890
*/
872
891
private def doTask (task : Task )(using State , Context ): Result = log(" checking " + task) {
873
892
val thisRef = task.value
893
+ thisRef.ensureObjectExists()
874
894
val tpl = thisRef.klass.defTree.asInstanceOf [TypeDef ].rhs.asInstanceOf [Template ]
875
895
876
896
val paramValues = tpl.constr.termParamss.flatten.map(param => param.symbol -> Hot ).toMap
@@ -1260,7 +1280,7 @@ object Semantic {
1260
1280
thisV.updateOuter(cls, res.value)
1261
1281
1262
1282
// follow constructor
1263
- if cls.hasSource then
1283
+ if cls.hasSource && ! thisV.isWarm then
1264
1284
tasks.append { () =>
1265
1285
printer.println(" init super class " + cls.show)
1266
1286
val res2 = thisV.callConstructor(ctor, args, source)
@@ -1331,7 +1351,7 @@ object Semantic {
1331
1351
var fieldsChanged = true
1332
1352
1333
1353
// class body
1334
- tpl.body.foreach {
1354
+ if ( ! thisV.isWarm) tpl.body.foreach {
1335
1355
case vdef : ValDef if ! vdef.symbol.is(Flags .Lazy ) && ! vdef.rhs.isEmpty =>
1336
1356
given Env = Env .empty
1337
1357
val res = eval(vdef.rhs, thisV, klass)
@@ -1342,11 +1362,8 @@ object Semantic {
1342
1362
case _ : MemberDef =>
1343
1363
1344
1364
case tree =>
1345
- thisV match
1346
- case thisRef : ThisRef =>
1347
- if fieldsChanged then thisRef.tryPromoteCurrentObject
1348
- fieldsChanged = false
1349
- case _ =>
1365
+ if fieldsChanged then thisV.asInstanceOf [ThisRef ].tryPromoteCurrentObject
1366
+ fieldsChanged = false
1350
1367
1351
1368
given Env = Env .empty
1352
1369
errorBuffer ++= eval(tree, thisV, klass).errors
0 commit comments