@@ -306,8 +306,11 @@ class Semantic {
306
306
307
307
case addr : Addr =>
308
308
val target = if needResolve then resolve(addr.klass, field) else field
309
+ val trace1 = trace.add(source)
309
310
if target.is(Flags .Lazy ) then
310
- value.call(target, Nil , superType = NoType , source, needResolve = false )
311
+ given Trace = trace1
312
+ val rhs = target.defTree.asInstanceOf [ValDef ].rhs
313
+ eval(rhs, addr, target.owner.asClass, cacheResult = true )
311
314
else
312
315
val obj = heap(addr)
313
316
if obj.fields.contains(target) then
@@ -357,12 +360,15 @@ class Semantic {
357
360
resolveSuper(addr.klass, superType, meth)
358
361
else
359
362
resolve(addr.klass, meth)
360
- if target.isOneOf(Flags .Method | Flags .Lazy ) then
363
+
364
+ if target.isOneOf(Flags .Method ) then
365
+ val trace1 = trace.add(source)
361
366
if target.hasSource then
367
+ given Trace = trace1
362
368
val cls = target.owner.enclosingClass.asClass
363
369
if target.isPrimaryConstructor then
364
370
val tpl = cls.defTree.asInstanceOf [TypeDef ].rhs.asInstanceOf [Template ]
365
- eval(tpl, addr, cls, cacheResult = true )( using env, ctx, trace.add(cls.defTree), promoted)
371
+ eval(tpl, addr, cls, cacheResult = true )
366
372
else
367
373
val rhs = target.defTree.asInstanceOf [ValOrDefDef ].rhs
368
374
eval(rhs, addr, cls, cacheResult = true )
@@ -392,15 +398,18 @@ class Semantic {
392
398
393
399
/** Handle a new expression `new p.C` where `p` is abstracted by `value` */
394
400
def instantiate (klass : ClassSymbol , ctor : Symbol , args : List [Value ], source : Tree ): Contextual [Result ] =
401
+ val trace1 = trace.add(source)
395
402
value match {
396
403
case Hot =>
397
404
Result (Hot , Errors .empty)
398
405
399
406
case Cold =>
400
- val error = CallCold (ctor, source, trace .toVector)
407
+ val error = CallCold (ctor, source, trace1 .toVector)
401
408
Result (Hot , error :: Nil )
402
409
403
410
case addr : Addr =>
411
+ given Trace = trace1
412
+
404
413
// widen the outer to finitize addresses
405
414
val outer = addr match
406
415
case Warm (_, _ : Warm , _, _) => Cold
@@ -653,17 +662,15 @@ class Semantic {
653
662
// check args
654
663
val (errors, args) = evalArgs(argss.flatten, thisV, klass)
655
664
656
- val trace2 : Trace = trace.add(expr)
657
-
658
665
ref match
659
666
case Select (supert : Super , _) =>
660
667
val SuperType (thisTp, superTp) = supert.tpe
661
668
val thisValue2 = resolveThis(thisTp.classSymbol.asClass, thisV, klass, ref)
662
- Result (thisValue2, errors).call(ref.symbol, args, superTp, expr)( using env, ctx, trace2)
669
+ Result (thisValue2, errors).call(ref.symbol, args, superTp, expr)
663
670
664
671
case Select (qual, _) =>
665
672
val res = eval(qual, thisV, klass) ++ errors
666
- res.call(ref.symbol, args, superType = NoType , source = expr)( using env, ctx, trace2)
673
+ res.call(ref.symbol, args, superType = NoType , source = expr)
667
674
668
675
case id : Ident =>
669
676
id.tpe match
@@ -675,7 +682,7 @@ class Semantic {
675
682
thisValue2.call(id.symbol, args, superType = NoType , expr, needResolve = false )
676
683
case TermRef (prefix, _) =>
677
684
val res = cases(prefix, thisV, klass, id) ++ errors
678
- res.call(id.symbol, args, superType = NoType , source = expr)( using env, ctx, trace2)
685
+ res.call(id.symbol, args, superType = NoType , source = expr)
679
686
680
687
case Select (qualifier, name) =>
681
688
eval(qualifier, thisV, klass).select(expr.symbol, expr)
@@ -870,7 +877,7 @@ class Semantic {
870
877
// follow constructor
871
878
if cls.hasSource then
872
879
printer.println(" init super class " + cls.show)
873
- val res2 = thisV.call(ctor, args, superType = NoType , source)( using env, ctx, trace.add(source))
880
+ val res2 = thisV.call(ctor, args, superType = NoType , source)
874
881
errorBuffer ++= res2.errors
875
882
876
883
// parents
@@ -957,13 +964,14 @@ class Semantic {
957
964
object Semantic {
958
965
959
966
// ----- Utility methods and extractors --------------------------------
967
+ inline def use [T , R ](v : T )(inline op : T ?=> R ): R = op(using v)
960
968
961
969
def typeRefOf (tp : Type )(using Context ): TypeRef = tp.dealias.typeConstructor match {
962
970
case tref : TypeRef => tref
963
971
case hklambda : HKTypeLambda => typeRefOf(hklambda.resType)
964
972
}
965
973
966
- opaque type Arg = Tree | ByNameArg
974
+ type Arg = Tree | ByNameArg
967
975
case class ByNameArg (tree : Tree )
968
976
969
977
extension (arg : Arg )
0 commit comments