Skip to content

Commit 6b0cafa

Browse files
committed
Simplify ClassOf phase
Make use of Definitions as the repository for standard symbols in Predef.
1 parent a2c3956 commit 6b0cafa

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ class Definitions {
221221

222222
lazy val Predef_conformsR = ScalaPredefModule.requiredMethodRef("$conforms")
223223
def Predef_conforms(implicit ctx: Context) = Predef_conformsR.symbol
224+
lazy val Predef_classOfR = ScalaPredefModule.requiredMethodRef("classOf")
225+
def Predef_classOf(implicit ctx: Context) = Predef_classOfR.symbol
224226

225227
lazy val ScalaRuntimeModuleRef = ctx.requiredModuleRef("scala.runtime.ScalaRunTime")
226228
def ScalaRuntimeModule(implicit ctx: Context) = ScalaRuntimeModuleRef.symbol

src/dotty/tools/dotc/transform/ClassOf.scala

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,8 @@ class ClassOf extends MiniPhaseTransform {
2121

2222
override def phaseName: String = "classOf"
2323

24-
private var classOfMethod: TermSymbol = _
25-
26-
override def prepareForUnit(tree: tpd.Tree)(implicit ctx: Context): TreeTransform = {
27-
classOfMethod = defn.ScalaPredefModule.requiredMethod(nme.classOf)
28-
this
29-
}
30-
3124
override def transformTypeApply(tree: TypeApply)(implicit ctx: Context, info: TransformerInfo): Tree =
32-
if (tree.symbol eq classOfMethod) {
25+
if (tree.symbol eq defn.Predef_classOf) {
3326
val targ = tree.args.head.tpe
3427
clsOf(targ).ensureConforms(tree.tpe).withPos(tree.pos)
3528
}

0 commit comments

Comments
 (0)