diff options
author | Paul Phillips <paulp@improving.org> | 2011-01-20 16:19:27 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-01-20 16:19:27 +0000 |
commit | 7a9f1437ab88403d8a9611c0790d583996db96c3 (patch) | |
tree | 7354618b380146273043fb7b4ac6e6e89c878724 /src | |
parent | 2d11a5bd46d1246f097507772e0eb6d5426db4d4 (diff) | |
download | scala-7a9f1437ab88403d8a9611c0790d583996db96c3.tar.gz scala-7a9f1437ab88403d8a9611c0790d583996db96c3.tar.bz2 scala-7a9f1437ab88403d8a9611c0790d583996db96c3.zip |
Made ().## and null.## not crash anymore.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/Erasure.scala | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 250101a636..7bba5fa227 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -400,21 +400,12 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer with ast. } val deconstMap = new TypeMap { - def apply(tp: Type): Type = tp match { - case PolyType(_, _) => mapOver(tp) - case MethodType(_, _) => mapOver(tp) // nullarymethod was eliminated during uncurry - case _ => tp.deconst - } - } - - /** The symbol which is called by a bridge; - * @pre phase > erasure - */ - def bridgedSym(bridge: Symbol) = - bridge.owner.info.nonPrivateDecl(bridge.name) suchThat { sym => - !sym.isBridge && matchesType(sym.tpe, bridge.tpe, true) && - (sym.tpe.resultType <:< bridge.tpe.resultType) + def apply(tp: Type): Type = tp match { + case PolyType(_, _) => mapOver(tp) + case MethodType(_, _) => mapOver(tp) // nullarymethod was eliminated during uncurry + case _ => tp.deconst } + } // -------- erasure on trees ------------------------------------------ @@ -970,7 +961,17 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer with ast. args) case Apply(fn @ Select(qual, _), Nil) if (fn.symbol == Any_## || fn.symbol == Object_##) => - Apply(gen.mkAttributedRef(scalaRuntimeHash), List(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. We also crash on null.## but unless we want to implement + // my good idea that null.## works (like null == "abc" works) we have to NPE. + val arg = qual.tpe.typeSymbol match { + case UnitClass => BLOCK(qual, REF(BoxedUnit_UNIT)) // ({ expr; UNIT }).## + case NullClass => Typed(qual, TypeTree(ObjectClass.tpe)) // (null: Object).## + case _ => qual + } + Apply(gen.mkAttributedRef(scalaRuntimeHash), List(arg)) case Apply(fn, args) => if (fn.symbol == Any_asInstanceOf) |