summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-02-01 08:26:45 +0000
committerPaul Phillips <paulp@improving.org>2011-02-01 08:26:45 +0000
commit94bb0a90131ce7f4a228274b8915afb26d64b31c (patch)
tree8da3cd069ed1c0ed9ad15e5b279cc1d8f3413307 /src
parent581e82f87f0ed4a2a484b00ac04c0bc667d201f9 (diff)
downloadscala-94bb0a90131ce7f4a228274b8915afb26d64b31c.tar.gz
scala-94bb0a90131ce7f4a228274b8915afb26d64b31c.tar.bz2
scala-94bb0a90131ce7f4a228274b8915afb26d64b31c.zip
I found more situations where primitive types w...
I found more situations where primitive types were appearing in signatures. I hacked in a flag which says boxing is or is not allowed. The code is getting hideous: foortunately I have it mostly rewritten, but I wanted to fix this bug now. No review.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/transform/Erasure.scala62
1 files changed, 31 insertions, 31 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala
index ccebcb62ea..70ecea4db5 100644
--- a/src/compiler/scala/tools/nsc/transform/Erasure.scala
+++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala
@@ -226,38 +226,38 @@ abstract class Erasure extends AddInterfaces
* type for constructors.
*/
def javaSig(sym0: Symbol, info: Type): Option[String] = atPhase(currentRun.erasurePhase) {
- def jsig(tp: Type): String = jsig2(false, Nil, tp)
-
- def boxedSig(tp: Type) = (boxedClass get tp.typeSymbol) match {
- case Some(boxed) => jsig(boxed.tpe)
- case None => jsig(tp)
+ def jsig(tp: Type, mustBox: Boolean) = {
+ (boxedClass get tp.typeSymbol) match {
+ case Some(boxed) if mustBox => jsig2(false, true, Nil, boxed.tpe)
+ case _ => jsig2(false, mustBox, Nil, tp)
+ }
}
def hiBounds(bounds: TypeBounds): List[Type] = bounds.hi.normalize match {
case RefinedType(parents, _) => parents map normalize
case tp => List(tp)
}
- def jsig2(toplevel: Boolean, tparams: List[Symbol], tp0: Type): String = {
+ def jsig2(toplevel: Boolean, mustBox: Boolean, tparams: List[Symbol], tp0: Type): String = {
val tp = tp0.dealias
tp match {
case st: SubType =>
- jsig2(toplevel, tparams, st.supertype)
+ jsig2(toplevel, mustBox, tparams, st.supertype)
case ExistentialType(tparams, tpe) =>
- jsig2(toplevel, tparams, tpe)
+ jsig2(toplevel, true, tparams, tpe)
case TypeRef(pre, sym, args) =>
def argSig(tp: Type) =
if (tparams contains tp.typeSymbol) {
val bounds = tp.typeSymbol.info.bounds
if (AnyRefClass.tpe <:< bounds.hi) {
if (bounds.lo <:< NullClass.tpe) "*"
- else "-" + boxedSig(bounds.lo)
+ else "-" + jsig(bounds.lo, true)
}
- else "+" + boxedSig(bounds.hi)
+ else "+" + jsig(bounds.hi, true)
}
else if (tp.typeSymbol == UnitClass) {
- jsig(ObjectClass.tpe)
+ jsig(ObjectClass.tpe, true)
} else {
- boxedSig(tp)
+ jsig(tp, true)
}
def classSig = (
"L"+atPhase(currentRun.icodePhase)(sym.fullName + global.genJVM.moduleSuffix(sym)).replace('.', '/')
@@ -266,19 +266,19 @@ abstract class Erasure extends AddInterfaces
// If args isEmpty, Array is being used as a higher-kinded type
if (sym == ArrayClass && args.nonEmpty) {
- if (unboundedGenericArrayLevel(tp) == 1) jsig(ObjectClass.tpe)
- else ARRAY_TAG.toString+(args map jsig).mkString
+ if (unboundedGenericArrayLevel(tp) == 1) jsig(ObjectClass.tpe, true)
+ else ARRAY_TAG.toString+(args map (x => jsig(x, false))).mkString
}
else if (isTypeParameterInSig(sym))
TVAR_TAG.toString+sym.name+";"
else if (sym == AnyClass || sym == AnyValClass || sym == SingletonClass)
- jsig(ObjectClass.tpe)
+ jsig(ObjectClass.tpe, mustBox)
else if (sym == UnitClass)
- jsig(BoxedUnitClass.tpe)
+ jsig(BoxedUnitClass.tpe, mustBox)
else if (sym == NothingClass)
- jsig(RuntimeNothingClass.tpe)
+ jsig(RuntimeNothingClass.tpe, mustBox)
else if (sym == NullClass)
- jsig(RuntimeNullClass.tpe)
+ jsig(RuntimeNullClass.tpe, mustBox)
else if (isValueClass(sym))
abbrvTag(sym).toString
else if (sym.isClass) {
@@ -286,7 +286,7 @@ abstract class Erasure extends AddInterfaces
dotCleanup(
(
if (needsJavaSig(preRebound)) {
- val s = jsig(preRebound)
+ val s = jsig(preRebound, mustBox)
if (s.charAt(0) == 'L') s.substring(0, s.length - 1) + classSigSuffix
else classSig
}
@@ -299,44 +299,44 @@ abstract class Erasure extends AddInterfaces
)
)
}
- else jsig(erasure(tp))
+ else jsig(erasure(tp), mustBox)
case PolyType(tparams, restpe) =>
assert(tparams.nonEmpty)
def boundSig(bounds: List[Type]) = {
val (isTrait, isClass) = bounds partition (_.typeSymbol.isTrait)
":" + (
- if (isClass.isEmpty) "" else boxedSig(isClass.head)
+ if (isClass.isEmpty) "" else jsig(isClass.head, true)
) + (
- isTrait map (x => ":" + boxedSig(x)) mkString
+ isTrait map (x => ":" + jsig(x, true)) mkString
)
}
def paramSig(tsym: Symbol) = tsym.name + boundSig(hiBounds(tsym.info.bounds))
val paramString = if (toplevel) tparams map paramSig mkString ("<", "", ">") else ""
- paramString + jsig(restpe)
+ paramString + jsig(restpe, false)
case MethodType(params, restpe) =>
- "("+(params map (_.tpe) map jsig).mkString+")"+
- (if (restpe.typeSymbol == UnitClass || sym0.isConstructor) VOID_TAG.toString else jsig(restpe))
+ "("+(params map (_.tpe) map (x => jsig(x, false))).mkString+")"+
+ (if (restpe.typeSymbol == UnitClass || sym0.isConstructor) VOID_TAG.toString else jsig(restpe, false))
case RefinedType(parents, decls) if (!parents.isEmpty) =>
- boxedSig(parents.head)
+ jsig(parents.head, mustBox)
case ClassInfoType(parents, _, _) =>
- (parents map jsig).mkString
+ (parents map (x => jsig(x, true))).mkString
case AnnotatedType(_, atp, _) =>
- jsig(atp)
+ jsig(atp, mustBox)
case BoundedWildcardType(bounds) =>
println("something's wrong: "+sym0+":"+sym0.tpe+" has a bounded wildcard type")
- jsig(bounds.hi)
+ jsig(bounds.hi, true)
case _ =>
val etp = erasure(tp)
if (etp eq tp) throw new UnknownSig
- else jsig(etp)
+ else jsig(etp, mustBox)
}
}
if (needsJavaSig(info)) {
try {
//println("Java sig of "+sym0+" is "+jsig2(true, List(), sym0.info))//DEBUG
- Some(jsig2(true, List(), info))
+ Some(jsig2(true, false, Nil, info))
} catch {
case ex: UnknownSig => None
}