summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-07-19 21:15:41 +0000
committerPaul Phillips <paulp@improving.org>2011-07-19 21:15:41 +0000
commitd34bd62d07cbaf6307b0c4713c39c6df114b4b6c (patch)
tree88abda55aecb653dcca72767d972989e52b2238b /src
parentb2f1b874686ea0d1aca5aca9b187998372970e61 (diff)
downloadscala-d34bd62d07cbaf6307b0c4713c39c6df114b4b6c.tar.gz
scala-d34bd62d07cbaf6307b0c4713c39c6df114b4b6c.tar.bz2
scala-d34bd62d07cbaf6307b0c4713c39c6df114b4b6c.zip
Fixed a subset of extant signature issues.
When generating signatures, one must be careful finding the name of a class, because sometimes things with a name like "Foo" need to appear in signatures as "Foo$". I could really use some help establishing tests here. Here's the diff of RedBlack's javap: < const #81 = Asciz ()Lscala/collection/immutable/RedBlack<TA;>.Empty;; --- > const #81 = Asciz ()Lscala/collection/immutable/RedBlack<TA;>.Empty$;; RedBlack and RedBlack$Empty$ are the only classfiles in the library outside of swing which are affected, which nicely explains their frequent appearance in past tickets. Review by grek.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/reflect/internal/transform/Erasure.scala18
-rw-r--r--src/compiler/scala/tools/nsc/transform/Erasure.scala19
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala2
3 files changed, 24 insertions, 15 deletions
diff --git a/src/compiler/scala/reflect/internal/transform/Erasure.scala b/src/compiler/scala/reflect/internal/transform/Erasure.scala
index 06f5009578..dec20a130e 100644
--- a/src/compiler/scala/reflect/internal/transform/Erasure.scala
+++ b/src/compiler/scala/reflect/internal/transform/Erasure.scala
@@ -50,14 +50,20 @@ trait Erasure {
case _ => 0
}
- // @M #2585 when generating a java generic signature that includes a selection of an inner class p.I, (p = `pre`, I = `cls`)
- // must rewrite to p'.I, where p' refers to the class that directly defines the nested class I
- // see also #2585 marker in javaSig: there, type arguments must be included (use pre.baseType(cls.owner))
- // requires cls.isClass
- @inline protected def rebindInnerClass(pre: Type, cls: Symbol): Type =
+ // @M #2585 when generating a java generic signature that includes
+ // a selection of an inner class p.I, (p = `pre`, I = `cls`) must
+ // rewrite to p'.I, where p' refers to the class that directly defines
+ // the nested class I.
+ //
+ // See also #2585 marker in javaSig: there, type arguments must be
+ // included (use pre.baseType(cls.owner)).
+ //
+ // This requires that cls.isClass.
+ @inline protected def rebindInnerClass(pre: Type, cls: Symbol): Type = {
if (cls.owner.isClass) cls.owner.tpe else pre // why not cls.isNestedClass?
+ }
- abstract class ErasureMap extends TypeMap {
+ abstract class ErasureMap extends TypeMap {
def mergeParents(parents: List[Type]): Type
def apply(tp: Type): Type = {
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala
index c4a728a091..fbb5a8dcde 100644
--- a/src/compiler/scala/tools/nsc/transform/Erasure.scala
+++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala
@@ -211,6 +211,13 @@ abstract class Erasure extends AddInterfaces
case RefinedType(parents, _) => parents map normalize
case tp => tp :: Nil
}
+ // Anything which could conceivably be a module (i.e. isn't known to be
+ // a type parameter or similar) must go through here or the signature is
+ // likely to end up with Foo<T>.Empty where it needs Foo<T>.Empty$.
+ def nameInSig(sym: Symbol) = "" + sym.name + global.genJVM.moduleSuffix(sym)
+ def fullNameInSig(sym: Symbol) = "L" + (
+ atPhase(currentRun.icodePhase)(sym.fullName('/') + global.genJVM.moduleSuffix(sym))
+ )
def jsig(tp0: Type, existentiallyBound: List[Symbol] = Nil, toplevel: Boolean = false, primitiveOK: Boolean = true): String = {
val tp = tp0.dealias
@@ -229,10 +236,6 @@ abstract class Erasure extends AddInterfaces
} else {
boxedSig(tp)
}
- def classSig: String =
- "L"+atPhase(currentRun.icodePhase)(sym.fullName + global.genJVM.moduleSuffix(sym)).replace('.', '/')
- def classSigSuffix: String =
- "."+sym.name
// If args isEmpty, Array is being used as a higher-kinded type
if (sym == ArrayClass && args.nonEmpty) {
@@ -241,7 +244,7 @@ abstract class Erasure extends AddInterfaces
}
else if (isTypeParameterInSig(sym, sym0)) {
assert(!sym.isAliasType, "Unexpected alias type: " + sym)
- TVAR_TAG.toString+sym.name+";"
+ "" + TVAR_TAG + sym.name + ";"
}
else if (sym == AnyClass || sym == AnyValClass || sym == SingletonClass)
jsig(ObjectClass.tpe)
@@ -263,10 +266,10 @@ abstract class Erasure extends AddInterfaces
(
if (needsJavaSig(preRebound)) {
val s = jsig(preRebound, existentiallyBound)
- if (s.charAt(0) == 'L') s.substring(0, s.length - 1) + classSigSuffix
- else classSig
+ if (s.charAt(0) == 'L') s.substring(0, s.length - 1) + "." + nameInSig(sym)
+ else fullNameInSig(sym)
}
- else classSig
+ else fullNameInSig(sym)
) + (
if (args.isEmpty) "" else
"<"+(args map argSig).mkString+">"
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index 713c5f607a..9e9c42cf90 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -780,7 +780,7 @@ trait Namers { self: Analyzer =>
// the namer phase must traverse this copy method to create default getters for its parameters.
// here, clazz is the ClassSymbol of the case class (not the module).
// @check: this seems to work only if the type completer of the class runs before the one of the
- // module class: the one from the module class removes the entry form caseClassOfModuleClass (see above).
+ // module class: the one from the module class removes the entry from caseClassOfModuleClass (see above).
if (clazz.isClass && !clazz.hasModuleFlag) {
Namers.this.caseClassOfModuleClass get companionModuleOf(clazz, context).moduleClass map { cdefRef =>
val cdef = cdefRef()