diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2017-02-21 16:02:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-21 16:02:11 +0100 |
commit | c96a9779891729981bb7644132d131de8e57c492 (patch) | |
tree | 704e0b473a41131ff6dfcde2e4b203d28df4512c /src/compiler/scala/tools/nsc/transform | |
parent | 76bfb9e0e5f38ce264f2a03490731f5865fa468f (diff) | |
parent | f85c62e33e6ec7e84ed5946f1d72f3f74941ab9e (diff) | |
download | scala-c96a9779891729981bb7644132d131de8e57c492.tar.gz scala-c96a9779891729981bb7644132d131de8e57c492.tar.bz2 scala-c96a9779891729981bb7644132d131de8e57c492.zip |
Merge pull request #5658 from retronym/topic/hashhash
Fix erasure of the qualifier of ##
Diffstat (limited to 'src/compiler/scala/tools/nsc/transform')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/Erasure.scala | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index e327a6658c..f8f0c193e2 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -1064,20 +1064,21 @@ abstract class Erasure extends InfoTransform } else if (args.isEmpty && interceptedMethods(fn.symbol)) { if (poundPoundMethods.contains(fn.symbol)) { + val qual1 = preErase(qual) // This is unattractive, but without it we crash here on ().## because after // erasure the ScalaRunTime.hash overload goes from Unit => Int to BoxedUnit => Int. // This must be because some earlier transformation is being skipped on ##, but so // far I don't know what. For null we now define null.## == 0. def staticsCall(methodName: TermName): Tree = { - val newTree = gen.mkMethodCall(RuntimeStaticsModule, methodName, qual :: Nil) + val newTree = gen.mkMethodCall(RuntimeStaticsModule, methodName, qual1 :: Nil) global.typer.typed(newTree) } - qual.tpe.typeSymbol match { - case UnitClass | NullClass => LIT(0) - case IntClass => qual - case s @ (ShortClass | ByteClass | CharClass) => numericConversion(qual, s) - case BooleanClass => If(qual, LIT(true.##), LIT(false.##)) + qual1.tpe.typeSymbol match { + case UnitClass | NullClass => BLOCK(qual1, LIT(0)) + case IntClass => qual1 + case s @ (ShortClass | ByteClass | CharClass) => numericConversion(qual1, s) + case BooleanClass => If(qual1, LIT(true.##), LIT(false.##)) case LongClass => staticsCall(nme.longHash) case FloatClass => staticsCall(nme.floatHash) case DoubleClass => staticsCall(nme.doubleHash) |