From 02e043c776114af40ce329a1b8741f9ae6bc5c8c Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 7 Mar 2011 11:56:47 +0000 Subject: More signature fixes and tests and generally be... More signature fixes and tests and generally being more sophisticated about our primitive squashing. These signatures belong in world-class museums but we are their shepherds for now. Closes #4317, no review. --- .../scala/tools/nsc/symtab/Definitions.scala | 1 + .../scala/tools/nsc/transform/Erasure.scala | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala index 011b753a9d..5f9a7d2816 100644 --- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala +++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala @@ -714,6 +714,7 @@ trait Definitions extends reflect.generic.StandardDefinitions { /** Is symbol a value class? */ def isValueClass(sym: Symbol) = scalaValueClassesSet(sym) + def isNonUnitValueClass(sym: Symbol) = (sym != UnitClass) && isValueClass(sym) /** Is symbol a boxed value class, e.g. java.lang.Integer? */ def isBoxedValueClass(sym: Symbol) = boxedValueClassesSet(sym) diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 7030b70082..3f94e165a1 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -237,6 +237,13 @@ abstract class Erasure extends AddInterfaces def javaSig(sym0: Symbol, info: Type): Option[String] = atPhase(currentRun.erasurePhase) { def jsig(tp: Type): String = jsig2(false, Nil, tp) + // Unit in return position is 'V', but that cannot appear elsewhere. + def unboxedSig(tpe: Type, isReturnPosition: Boolean) = { + val tsym = tpe.typeSymbol + if (isReturnPosition && (tsym == UnitClass || sym0.isConstructor)) VOID_TAG + else if (isNonUnitValueClass(tsym)) abbrvTag(tsym) + else jsig(tpe) + } def boxedSig(tp: Type) = jsig(squashBoxed(tp)) def squashBoxed(tp: Type) = if (boxedClass contains tp.typeSymbol) ObjectClass.tpe @@ -328,15 +335,14 @@ abstract class Erasure extends AddInterfaces def paramSig(tsym: Symbol) = tsym.name + boundSig(hiBounds(tsym.info.bounds)) val paramString = if (toplevel) tparams map paramSig mkString ("<", "", ">") else "" - paramString + jsig(restpe) + traceSig.seq("PolyType", Seq(tparams, restpe))(paramString + jsig(restpe)) case MethodType(params, restpe) => - val ressym = restpe.typeSymbol - "(%s)%s".format( - params map (x => jsig(x.tpe)) mkString, - if (ressym == UnitClass || sym0.isConstructor) VOID_TAG - else if (isValueClass(ressym)) abbrvTag(ressym) - else jsig(restpe) - ) + traceSig.seq("MethodType", Seq(params, restpe)) { + "(%s)%s".format( + params map (p => unboxedSig(p.tpe, false)) mkString, + unboxedSig(restpe, true) + ) + } case RefinedType(parent :: _, decls) => jsig(parent) case ClassInfoType(parents, _, _) => -- cgit v1.2.3