diff options
author | Paul Phillips <paulp@improving.org> | 2012-09-18 16:05:15 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-09-20 00:08:12 -0700 |
commit | a0c7acd7c382ae766d4cbc0963c21cc3b7b3cede (patch) | |
tree | f64f1e9857e77a87c8daa0c0f3428037a0c172e1 /src | |
parent | 3b120ff12891968d02296abb60adb9137d335ae2 (diff) | |
download | scala-a0c7acd7c382ae766d4cbc0963c21cc3b7b3cede.tar.gz scala-a0c7acd7c382ae766d4cbc0963c21cc3b7b3cede.tar.bz2 scala-a0c7acd7c382ae766d4cbc0963c21cc3b7b3cede.zip |
Fix for SI-6344, value class generic signatures.
Value classes mostly erase to the erasure of the
underlying type. Not everything in the checkfile
looks correct, but I know from experience I can
spend the rest of my life poking at erasures, so
let's try to book some progress.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/Erasure.scala | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index b3b0c82d38..66c9bb9fa0 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -223,6 +223,24 @@ abstract class Erasure extends AddInterfaces } else { boxedSig(tp) } + def classSig = { + val preRebound = pre.baseType(sym.owner) // #2585 + dotCleanup( + ( + if (needsJavaSig(preRebound)) { + val s = jsig(preRebound, existentiallyBound) + if (s.charAt(0) == 'L') s.substring(0, s.length - 1) + "." + sym.javaSimpleName + else fullNameInSig(sym) + } + else fullNameInSig(sym) + ) + ( + if (args.isEmpty) "" else + "<"+(args map argSig).mkString+">" + ) + ( + ";" + ) + ) + } // If args isEmpty, Array is being used as a type constructor if (sym == ArrayClass && args.nonEmpty) { @@ -246,25 +264,21 @@ abstract class Erasure extends AddInterfaces else if (sym == UnitClass) jsig(BoxedUnitClass.tpe) else abbrvTag(sym).toString } - else if (sym.isClass) { - val preRebound = pre.baseType(sym.owner) // #2585 - dotCleanup( - ( - if (needsJavaSig(preRebound)) { - val s = jsig(preRebound, existentiallyBound) - if (s.charAt(0) == 'L') s.substring(0, s.length - 1) + "." + sym.javaSimpleName - else fullNameInSig(sym) - } - else fullNameInSig(sym) - ) + ( - if (args.isEmpty) "" else - "<"+(args map argSig).mkString+">" - ) + ( - ";" - ) - ) + else if (sym.isDerivedValueClass) { + val unboxed = sym.derivedValueClassUnbox.info.finalResultType + val unboxedSeen = (tp memberType sym.derivedValueClassUnbox).finalResultType + def unboxedMsg = if (unboxed == unboxedSeen) "" else s", seen within ${sym.simpleName} as $unboxedSeen" + logResult(s"Erasure of value class $sym (underlying type $unboxed$unboxedMsg) is") { + if (isPrimitiveValueType(unboxedSeen) && !primitiveOK) + classSig + else + jsig(unboxedSeen, existentiallyBound, toplevel, primitiveOK) + } } - else jsig(erasure(sym0)(tp), existentiallyBound, toplevel, primitiveOK) + else if (sym.isClass) + classSig + else + jsig(erasure(sym0)(tp), existentiallyBound, toplevel, primitiveOK) case PolyType(tparams, restpe) => assert(tparams.nonEmpty) val poly = if (toplevel) polyParamSig(tparams) else "" |