Skip to content

Commit f5651b5

Browse files
committed
Revert ThisRef to previous version
1 parent 20ff7ca commit f5651b5

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@ class Checker extends Phase {
5353
mdef match
5454
case tdef: TypeDef if tdef.isClassDef =>
5555
val cls = tdef.symbol.asClass
56-
val ctor = cls.primaryConstructor
57-
val args = ctor.defTree.asInstanceOf[DefDef].termParamss.flatten.map(_ => Hot)
58-
val outer = Hot
59-
val thisRef = ThisRef(cls, outer, ctor, args)
56+
val thisRef = ThisRef(cls)
6057
given Trace = Trace.empty
6158
if shouldCheckClass(cls) then Semantic.addTask(thisRef)
6259
case _ =>

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ object Semantic {
8383
}
8484

8585
/** A reference to the object under initialization pointed by `this` */
86-
case class ThisRef(klass: ClassSymbol, outer: Value, ctor: Symbol, args: List[Value]) extends Ref {
86+
case class ThisRef(klass: ClassSymbol) extends Ref {
87+
val outer = Hot
8788
/** Caches initialized fields */
8889
val objekt = Objekt(klass, fields = mutable.Map.empty, outers = mutable.Map(klass -> outer))
8990
}
@@ -709,7 +710,7 @@ object Semantic {
709710
cls == defn.ObjectClass
710711

711712
// ----- Work list ---------------------------------------------------
712-
case class Task(value: ThisRef)(val trace: Trace)
713+
type Task = ThisRef
713714

714715
class WorkList private[Semantic]() {
715716
private var checkedTasks: Set[Task] = Set.empty
@@ -734,12 +735,14 @@ object Semantic {
734735
* This method should only be called from the work list scheduler.
735736
*/
736737
private def doTask(task: Task)(using State, Context): Unit = {
737-
val thisRef = task.value
738+
val thisRef = task
738739
val tpl = thisRef.klass.defTree.asInstanceOf[TypeDef].rhs.asInstanceOf[Template]
739740

741+
val paramValues = tpl.constr.termParamss.flatten.map(param => param.symbol -> Hot).toMap
742+
740743
given Promoted = Promoted.empty
741-
given Trace = task.trace
742-
given Env = Env(thisRef.ctor.defTree.asInstanceOf[DefDef], thisRef.args)
744+
given Trace = Trace.empty
745+
given Env = Env(paramValues)
743746

744747
val res = init(tpl, thisRef, thisRef.klass)
745748
res.errors.foreach(_.issue)
@@ -750,7 +753,7 @@ object Semantic {
750753
// ----- API --------------------------------
751754

752755
/** Add a checking task to the work list */
753-
def addTask(task: ThisRef)(using WorkList, Trace) = workList.addTask(Task(task)(trace))
756+
def addTask(task: ThisRef)(using WorkList) = workList.addTask(task)
754757

755758
/** Perform check on the work list until it becomes empty
756759
*

0 commit comments

Comments
 (0)