aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/transform/SyntheticMethods.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/SyntheticMethods.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/SyntheticMethods.scala')
-rw-r--r--src/dotty/tools/dotc/transform/SyntheticMethods.scala25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/dotty/tools/dotc/transform/SyntheticMethods.scala b/src/dotty/tools/dotc/transform/SyntheticMethods.scala
index fa931a379..a496f80ce 100644
--- a/src/dotty/tools/dotc/transform/SyntheticMethods.scala
+++ b/src/dotty/tools/dotc/transform/SyntheticMethods.scala
@@ -77,7 +77,7 @@ class SyntheticMethods(thisTransformer: DenotTransformer) {
coord = clazz.coord).enteredAfter(thisTransformer).asTerm
def forwardToRuntime(vrefss: List[List[Tree]]): Tree =
- ref(defn.runtimeMethod("_" + sym.name.toString)).appliedToArgs(This(clazz) :: vrefss.head)
+ ref(defn.runtimeMethodRef("_" + sym.name.toString)).appliedToArgs(This(clazz) :: vrefss.head)
def syntheticRHS(implicit ctx: Context): List[List[Tree]] => Tree = synthetic.name match {
case nme.hashCode_ if isDerivedValueClass(clazz) => vrefss => valueHashCodeBody
@@ -161,20 +161,17 @@ class SyntheticMethods(thisTransformer: DenotTransformer) {
}
/** The hashCode implementation for given symbol `sym`. */
- def hashImpl(sym: Symbol)(implicit ctx: Context): Tree = {
- val d = defn
- import d._
- sym.info.finalResultType.typeSymbol match {
- case UnitClass | NullClass => Literal(Constant(0))
- case BooleanClass => If(ref(sym), Literal(Constant(1231)), Literal(Constant(1237)))
- case IntClass => ref(sym)
- case ShortClass | ByteClass | CharClass => ref(sym).select(nme.toInt)
- case LongClass => ref(staticsMethod("longHash")).appliedTo(ref(sym))
- case DoubleClass => ref(staticsMethod("doubleHash")).appliedTo(ref(sym))
- case FloatClass => ref(staticsMethod("floatHash")).appliedTo(ref(sym))
- case _ => ref(staticsMethod("anyHash")).appliedTo(ref(sym))
+ def hashImpl(sym: Symbol)(implicit ctx: Context): Tree =
+ defn.scalaClassName(sym.info.finalResultType) match {
+ case tpnme.Unit | tpnme.Null => Literal(Constant(0))
+ case tpnme.Boolean => If(ref(sym), Literal(Constant(1231)), Literal(Constant(1237)))
+ case tpnme.Int => ref(sym)
+ case tpnme.Short | tpnme.Byte | tpnme.Char => ref(sym).select(nme.toInt)
+ case tpnme.Long => ref(defn.staticsMethod("longHash")).appliedTo(ref(sym))
+ case tpnme.Double => ref(defn.staticsMethod("doubleHash")).appliedTo(ref(sym))
+ case tpnme.Float => ref(defn.staticsMethod("floatHash")).appliedTo(ref(sym))
+ case _ => ref(defn.staticsMethod("anyHash")).appliedTo(ref(sym))
}
- }
/** The class
*