@@ -156,7 +156,7 @@ object Semantic:
156
156
def hasField (f : Symbol ) = fields.contains(f)
157
157
158
158
object Promoted :
159
- class PromotionInfo :
159
+ class PromotionInfo ( val entryClass : ClassSymbol ) :
160
160
var isCurrentObjectPromoted : Boolean = false
161
161
val values = mutable.Set .empty[Value ]
162
162
override def toString (): String = values.toString()
@@ -165,14 +165,15 @@ object Semantic:
165
165
opaque type Promoted = PromotionInfo
166
166
167
167
/** Note: don't use `val` to avoid incorrect sharing */
168
- def empty : Promoted = new PromotionInfo
168
+ def empty ( entryClass : ClassSymbol ) : Promoted = new PromotionInfo (entryClass)
169
169
170
170
extension (promoted : Promoted )
171
171
def isCurrentObjectPromoted : Boolean = promoted.isCurrentObjectPromoted
172
172
def promoteCurrent (thisRef : ThisRef ): Unit = promoted.isCurrentObjectPromoted = true
173
173
def contains (value : Value ): Boolean = promoted.values.contains(value)
174
174
def add (value : Value ): Unit = promoted.values += value
175
175
def remove (value : Value ): Unit = promoted.values -= value
176
+ def entryClass : ClassSymbol = promoted.entryClass
176
177
end extension
177
178
end Promoted
178
179
type Promoted = Promoted .Promoted
@@ -658,7 +659,7 @@ object Semantic:
658
659
659
660
def select (field : Symbol , receiver : Type , needResolve : Boolean = true ): Contextual [Value ] = log(" select " + field.show + " , this = " + value, printer, (_ : Value ).show) {
660
661
if promoted.isCurrentObjectPromoted then Hot
661
- else value match {
662
+ else value match
662
663
case Hot =>
663
664
Hot
664
665
@@ -710,7 +711,6 @@ object Semantic:
710
711
711
712
case RefSet (refs) =>
712
713
refs.map(_.select(field, receiver)).join
713
- }
714
714
}
715
715
716
716
def call (meth : Symbol , args : List [ArgInfo ], receiver : Type , superType : Type , needResolve : Boolean = true ): Contextual [Value ] = log(" call " + meth.show + " , args = " + args.map(_.value.show), printer, (_ : Value ).show) {
@@ -1230,7 +1230,7 @@ object Semantic:
1230
1230
1231
1231
@ tailrec
1232
1232
def iterate (): Unit = {
1233
- given Promoted = Promoted .empty
1233
+ given Promoted = Promoted .empty(thisRef.klass)
1234
1234
given Trace = Trace .empty.add(thisRef.klass.defTree)
1235
1235
given reporter : Reporter .BufferedReporter = new Reporter .BufferedReporter
1236
1236
@@ -1513,16 +1513,19 @@ object Semantic:
1513
1513
thisV.accessLocal(tmref, klass)
1514
1514
1515
1515
case tmref : TermRef =>
1516
- cases(tmref.prefix, thisV, klass).select(tmref.symbol, receiver = tmref.prefix)
1516
+ val cls = tmref.widenSingleton.classSymbol.asClass
1517
+ if cls.isStaticOwner && ! cls.isContainedIn(promoted.entryClass) then
1518
+ Hot
1519
+ else
1520
+ cases(tmref.prefix, thisV, klass).select(tmref.symbol, receiver = tmref.prefix)
1517
1521
1518
1522
case tp @ ThisType (tref) =>
1519
1523
val cls = tref.classSymbol.asClass
1520
1524
if cls.isStaticOwner && ! klass.isContainedIn(cls) then
1521
1525
// O.this outside the body of the object O
1522
1526
Hot
1523
1527
else
1524
- val value = resolveThis(cls, thisV, klass)
1525
- value
1528
+ resolveThis(cls, thisV, klass)
1526
1529
1527
1530
case _ : TermParamRef | _ : RecThis =>
1528
1531
// possible from checking effects of types
0 commit comments