@@ -129,7 +129,7 @@ class Semantic {
129
129
type Heap = Heap .Heap
130
130
131
131
import Heap ._
132
- def heap ( using h : Heap ) : Heap = h
132
+ val heap : Heap = Heap .empty
133
133
134
134
object Promoted {
135
135
/** Values that have been safely promoted */
@@ -205,7 +205,7 @@ class Semantic {
205
205
}
206
206
207
207
/** The state that threads through the interpreter */
208
- type Contextual [T ] = (Heap , Context , Trace , Promoted ) ?=> T
208
+ type Contextual [T ] = (Context , Trace , Promoted ) ?=> T
209
209
210
210
// ----- Error Handling -----------------------------------
211
211
@@ -268,7 +268,13 @@ class Semantic {
268
268
if obj.fields.contains(target) then
269
269
Result (obj.fields(target), Nil )
270
270
else if addr.isInstanceOf [Warm ] then
271
- if target.hasSource then
271
+ if target.is(Flags .ParamAccessor ) then
272
+ // possible for trait parameters
273
+ // see tests/init/neg/trait2.scala
274
+ //
275
+ // return `Hot` here, errors are reported in checking `ThisRef`
276
+ Result (Hot , Nil )
277
+ else if target.hasSource then
272
278
val rhs = target.defTree.asInstanceOf [ValOrDefDef ].rhs
273
279
eval(rhs, addr, target.owner.asClass, cacheResult = true )
274
280
else
@@ -310,7 +316,7 @@ class Semantic {
310
316
val cls = target.owner.enclosingClass.asClass
311
317
if target.isPrimaryConstructor then
312
318
val tpl = cls.defTree.asInstanceOf [TypeDef ].rhs.asInstanceOf [Template ]
313
- eval(tpl, addr, cls, cacheResult = true )(using heap, ctx, trace.add(tpl), promoted)
319
+ eval(tpl, addr, cls, cacheResult = true )(using ctx, trace.add(tpl), promoted)
314
320
else
315
321
val rhs = target.defTree.asInstanceOf [ValOrDefDef ].rhs
316
322
eval(rhs, addr, cls, cacheResult = true )
@@ -608,11 +614,11 @@ class Semantic {
608
614
case Select (supert : Super , _) =>
609
615
val SuperType (thisTp, superTp) = supert.tpe
610
616
val thisValue2 = resolveThis(thisTp.classSymbol.asClass, thisV, klass, ref)
611
- Result (thisValue2, errors).call(ref.symbol, superTp, expr)(using heap, ctx, trace2)
617
+ Result (thisValue2, errors).call(ref.symbol, superTp, expr)(using ctx, trace2)
612
618
613
619
case Select (qual, _) =>
614
620
val res = eval(qual, thisV, klass) ++ errors
615
- res.call(ref.symbol, superType = NoType , source = expr)(using heap, ctx, trace2)
621
+ res.call(ref.symbol, superType = NoType , source = expr)(using ctx, trace2)
616
622
617
623
case id : Ident =>
618
624
id.tpe match
@@ -624,7 +630,7 @@ class Semantic {
624
630
thisValue2.call(id.symbol, superType = NoType , expr, needResolve = false )
625
631
case TermRef (prefix, _) =>
626
632
val res = cases(prefix, thisV, klass, id) ++ errors
627
- res.call(id.symbol, superType = NoType , source = expr)(using heap, ctx, trace2)
633
+ res.call(id.symbol, superType = NoType , source = expr)(using ctx, trace2)
628
634
629
635
case Select (qualifier, name) =>
630
636
eval(qualifier, thisV, klass).select(expr.symbol, expr)
@@ -816,7 +822,7 @@ class Semantic {
816
822
817
823
// follow constructor
818
824
if cls.hasSource then
819
- val res2 = thisV.call(ctor, superType = NoType , source)(using heap, ctx, trace.add(source))
825
+ val res2 = thisV.call(ctor, superType = NoType , source)(using ctx, trace.add(source))
820
826
errorBuffer ++= res2.errors
821
827
822
828
// parents
0 commit comments