aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/transform/ClassOf.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-11-07 12:58:33 +0100
committerMartin Odersky <odersky@gmail.com>2015-11-09 15:45:37 +0100
commit8978ae6dfabae562fb5dcf4c7f66983d4d865892 (patch)
tree999cd971a10b46ec307c550a5af464329495c6c9 /src/dotty/tools/dotc/transform/ClassOf.scala
parentf2b61ce055fccf96e305ef43fca8abef8a912f33 (diff)
downloaddotty-8978ae6dfabae562fb5dcf4c7f66983d4d865892.tar.gz
dotty-8978ae6dfabae562fb5dcf4c7f66983d4d865892.tar.bz2
dotty-8978ae6dfabae562fb5dcf4c7f66983d4d865892.zip
First versions of Definitions based on TypeRefs not Symbols.
Symbols are not stable between runs, so if some symbol referred to from Definitions gets recompiled, there are then two Symbols that are both visible, one referenced from Definitions, the other the one that got compiled. Thos led to a crash when e.g. compiling scala.Short, because the newly compiled symbol was not recognized as a primitive value class. The present commit tries to make systematic changes without regard to simplicity or aesthetics. This will be polished in future commits. // ### comments signal areas that need further attention.
Diffstat (limited to 'src/dotty/tools/dotc/transform/ClassOf.scala')
-rw-r--r--src/dotty/tools/dotc/transform/ClassOf.scala29
1 files changed, 7 insertions, 22 deletions
diff --git a/src/dotty/tools/dotc/transform/ClassOf.scala b/src/dotty/tools/dotc/transform/ClassOf.scala
index 4d6bf2dc9..cc7f8bad3 100644
--- a/src/dotty/tools/dotc/transform/ClassOf.scala
+++ b/src/dotty/tools/dotc/transform/ClassOf.scala
@@ -24,30 +24,15 @@ class ClassOf extends MiniPhaseTransform {
private var classOfMethod: TermSymbol = _
override def prepareForUnit(tree: tpd.Tree)(implicit ctx: Context): TreeTransform = {
- val predefModule = ctx.definitions.ScalaPredefModule
- classOfMethod = ctx.requiredMethod(predefModule.moduleClass.asClass, nme.classOf)
+ val predefModule = ctx.definitions.ScalaPredefModuleRef
+ classOfMethod = ctx.requiredMethod(predefModule, nme.classOf)
this
}
- override def transformTypeApply(tree: TypeApply)(implicit ctx: Context, info: TransformerInfo): Tree = {
+ override def transformTypeApply(tree: TypeApply)(implicit ctx: Context, info: TransformerInfo): Tree =
if (tree.symbol eq classOfMethod) {
- val tp = tree.args.head.tpe
- val defn = ctx.definitions
- val claz = tp.classSymbol
-
- def TYPE(module: TermSymbol) = ref(module).select(nme.TYPE_).ensureConforms(tree.tpe)
- claz match {
- case defn.BooleanClass => TYPE(defn.BoxedBooleanModule)
- case defn.ByteClass => TYPE(defn.BoxedByteModule)
- case defn.ShortClass => TYPE(defn.BoxedShortModule)
- case defn.CharClass => TYPE(defn.BoxedCharModule)
- case defn.IntClass => TYPE(defn.BoxedIntModule)
- case defn.LongClass => TYPE(defn.BoxedLongModule)
- case defn.FloatClass => TYPE(defn.BoxedFloatModule)
- case defn.DoubleClass => TYPE(defn.BoxedDoubleModule)
- case defn.UnitClass => TYPE(defn.BoxedVoidModule)
- case _ => Literal(Constant(TypeErasure.erasure(tp)))
- }
- } else tree
- }
+ val targ = tree.args.head.tpe
+ tree.clsOf(targ, Literal(Constant(TypeErasure.erasure(targ))))
+ }
+ else tree
}