Skip to content

Commit ff0d699

Browse files
author
EnzeXing
committed
Adding TODOs
1 parent b9922ce commit ff0d699

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class Objects(using Context @constructorOnly):
114114
/**
115115
* A reference caches the values for outers and immutable fields.
116116
*/
117-
sealed abstract class Scope(using trace: Trace):
117+
sealed abstract class Scope(using trace: Trace): // TODO: rename it to reflect that it is key to the heap
118118
def isObjectRef: Boolean = this.isInstanceOf[ObjectRef]
119119

120120
def getTrace: Trace = trace
@@ -293,7 +293,11 @@ class Objects(using Context @constructorOnly):
293293

294294
def toValueSet: ValueSet = ValueSet(scopes.asInstanceOf[Set[ValueElement]])
295295

296-
case class Package(packageModuleClass: ClassSymbol) extends Value:
296+
def lookupSymbol(sym: Symbol)(using Heap.MutableData) = scopes.map(_.valValue(sym)).join
297+
298+
def outers(using Heap.MutableData): ScopeSet = scopes.map(_.outer).join
299+
300+
case class Package(packageModuleClass: ClassSymbol) extends Value: // TODO: try to remove packages
297301
def show(using Context): String = "Package(" + packageModuleClass.show + ")"
298302

299303
object Package:
@@ -448,7 +452,7 @@ class Objects(using Context @constructorOnly):
448452
val outerThis = resolveThisRecur(targetClass, resultSet)
449453
Some((outerThis, resultSet))
450454
else
451-
val outerScopes = scopeSet.scopes.map(_.outer).join
455+
val outerScopes = scopeSet.outers
452456
resolveEnvRecur(target, outerScopes, bySymbol)
453457

454458

@@ -1184,7 +1188,7 @@ class Objects(using Context @constructorOnly):
11841188
// Assume forward reference check is doing a good job
11851189
val scopesOwnedByOthers = scopeSet.scopes.filter(_.owner != State.currentObject)
11861190
if scopesOwnedByOthers.isEmpty then
1187-
scopeSet.scopes.map(_.varValue(sym)).join
1191+
scopeSet.lookupSymbol(sym)
11881192
else
11891193
errorReadOtherStaticObject(State.currentObject, scopesOwnedByOthers.head)
11901194
Bottom
@@ -1195,7 +1199,7 @@ class Objects(using Context @constructorOnly):
11951199
eval(rhs, thisV, sym.enclosingClass.asClass, cacheResult = true)
11961200
else
11971201
// Assume forward reference check is doing a good job
1198-
val value = scopeSet.scopes.map(_.varValue(sym)).join
1202+
val value = scopeSet.lookupSymbol(sym)
11991203
if isByNameParam(sym) then
12001204
evalByNameParam(value)
12011205
else
@@ -1835,7 +1839,7 @@ class Objects(using Context @constructorOnly):
18351839
}
18361840

18371841
// parents
1838-
def initParent(parent: Tree, tasks: Tasks) =
1842+
def initParent(parent: Tree, tasks: Tasks) = // TODO: store the parent objects and resolve `p.this` for parent classes `p`
18391843
parent match
18401844
case tree @ Block(stats, NewExpr(tref, New(tpt), ctor, argss)) => // can happen
18411845
evalExprs(stats, thisV, klass)
@@ -1933,9 +1937,9 @@ class Objects(using Context @constructorOnly):
19331937
if klass == target then
19341938
scopeSet.toValueSet
19351939
else
1936-
resolveThisRecur(target, scopeSet.scopes.map(_.outer).join)
1940+
resolveThisRecur(target, scopeSet.outers)
19371941
else
1938-
resolveThisRecur(target, scopeSet.scopes.map(_.outer).join)
1942+
resolveThisRecur(target, scopeSet.outers)
19391943

19401944
/** Resolve C.this that appear in `D.this`
19411945
*

compiler/test/dotc/neg-init-global-scala2-library-tasty.excludelist

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ global-list.scala
1515
t5366.scala
1616
mutable-read7.scala
1717
t9115.scala
18-
Color.scala
18+
Color.scala
19+
unapplySeq-implicit-arg2.scala
20+
unapplySeq-implicit-arg3.scala

0 commit comments

Comments
 (0)