diff options
author | Martin Odersky <odersky@gmail.com> | 2017-03-31 10:43:18 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2017-03-31 10:43:18 +0200 |
commit | aa2522c880d78d172b3af6cc4d336f2ebe447b18 (patch) | |
tree | 3f5c5a5e9f3fb05817aecc35fcc25f4a4bcdf550 /compiler | |
parent | 6aba35fc6aff1f7de4d0395df189cd75ed0acff1 (diff) | |
download | dotty-aa2522c880d78d172b3af6cc4d336f2ebe447b18.tar.gz dotty-aa2522c880d78d172b3af6cc4d336f2ebe447b18.tar.bz2 dotty-aa2522c880d78d172b3af6cc4d336f2ebe447b18.zip |
Use full name of case classes for hashing
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/src/dotty/tools/dotc/transform/SyntheticMethods.scala | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/src/dotty/tools/dotc/transform/SyntheticMethods.scala b/compiler/src/dotty/tools/dotc/transform/SyntheticMethods.scala index bb11348c2..13af7e112 100644 --- a/compiler/src/dotty/tools/dotc/transform/SyntheticMethods.scala +++ b/compiler/src/dotty/tools/dotc/transform/SyntheticMethods.scala @@ -144,12 +144,13 @@ class SyntheticMethods(thisTransformer: DenotTransformer) { /** The class * + * package p * case class C(x: T, y: T) * * gets the hashCode method: * * def hashCode: Int = { - * <synthetic> var acc: Int = "C".hashCode // constant folded + * <synthetic> var acc: Int = "p.C".hashCode // constant folded * acc = Statics.mix(acc, x); * acc = Statics.mix(acc, Statics.this.anyHash(y)); * Statics.finalizeHash(acc, 2) @@ -157,7 +158,7 @@ class SyntheticMethods(thisTransformer: DenotTransformer) { */ def caseHashCodeBody(implicit ctx: Context): Tree = { val acc = ctx.newSymbol(ctx.owner, "acc".toTermName, Mutable | Synthetic, defn.IntType, coord = ctx.owner.pos) - val accDef = ValDef(acc, Literal(Constant(clazz.name.toString.hashCode))) + val accDef = ValDef(acc, Literal(Constant(clazz.fullName.toString.hashCode))) val mixes = for (accessor <- accessors.toList) yield Assign(ref(acc), ref(defn.staticsMethod("mix")).appliedTo(ref(acc), hashImpl(accessor))) val finish = ref(defn.staticsMethod("finalizeHash")).appliedTo(ref(acc), Literal(Constant(accessors.size))) |