diff options
author | Paul Phillips <paulp@improving.org> | 2011-03-07 11:56:47 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-03-07 11:56:47 +0000 |
commit | 02e043c776114af40ce329a1b8741f9ae6bc5c8c (patch) | |
tree | a1f7a8a2aae97d2f047430aaebb2b8ed6e95f79b /src | |
parent | 5f491e5d037b799476747f0dee6ea50fe87c269b (diff) | |
download | scala-02e043c776114af40ce329a1b8741f9ae6bc5c8c.tar.gz scala-02e043c776114af40ce329a1b8741f9ae6bc5c8c.tar.bz2 scala-02e043c776114af40ce329a1b8741f9ae6bc5c8c.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/Definitions.scala | 1 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/Erasure.scala | 22 |
2 files changed, 15 insertions, 8 deletions
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, _, _) => |