diff options
author | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2012-09-25 08:24:48 -0700 |
---|---|---|
committer | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2012-09-25 08:24:48 -0700 |
commit | f284ac55c931249a49499a7831de4d25213d34b8 (patch) | |
tree | da3f735467a658a9209eef336b70759b13239582 /src | |
parent | ebeb3684b2e80f826f55276c760c192510b3b84d (diff) | |
parent | a0c7acd7c382ae766d4cbc0963c21cc3b7b3cede (diff) | |
download | scala-f284ac55c931249a49499a7831de4d25213d34b8.tar.gz scala-f284ac55c931249a49499a7831de4d25213d34b8.tar.bz2 scala-f284ac55c931249a49499a7831de4d25213d34b8.zip |
Merge pull request #1345 from paulp/issue/6344
Possible fix for SI-6344, value class generic signatures.
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 072d823c60..5d5e150662 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -225,6 +225,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) { @@ -248,25 +266,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 "" |