diff options
author | Paul Phillips <paulp@improving.org> | 2011-03-06 10:07:51 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-03-06 10:07:51 +0000 |
commit | bc9a3475f308e78de193e4072f11e2edb7f7a72b (patch) | |
tree | 5c33f619851c97d015fb3d7daba21fc83483e9c2 | |
parent | a3d2d3b1ceaa7090a993b4a4f0ea53f4fe343e08 (diff) | |
download | scala-bc9a3475f308e78de193e4072f11e2edb7f7a72b.tar.gz scala-bc9a3475f308e78de193e4072f11e2edb7f7a72b.tar.bz2 scala-bc9a3475f308e78de193e4072f11e2edb7f7a72b.zip |
Re-enabling the disabled signature test along w...
Re-enabling the disabled signature test along with changes which allow
it to pass. Closes #4238 again, no review. (But would anyone like to
expand the signature tests? Great idea, extempore!)
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/Erasure.scala | 47 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/util/Tracer.scala | 3 | ||||
-rw-r--r-- | test/files/jvm/JavaInteraction.scala | 2 | ||||
-rw-r--r-- | test/files/jvm/t2585.check (renamed from test/disabled/jvm/t2585.check) | 0 | ||||
-rw-r--r-- | test/files/jvm/t2585/Test.java (renamed from test/disabled/jvm/t2585/Test.java) | 0 | ||||
-rw-r--r-- | test/files/jvm/t2585/genericouter.scala (renamed from test/disabled/jvm/t2585/genericouter.scala) | 0 |
6 files changed, 29 insertions, 23 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index a6c862c19d..dcc6ab044c 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -202,14 +202,15 @@ abstract class Erasure extends AddInterfaces private def needsJavaSig(tp: Type) = !settings.Ynogenericsig.value && NeedsSigCollector.collect(tp) // only refer to type params that will actually make it into the sig, this excludes: - // * higher-order type parameters (aka !sym.owner.isTypeParameterOrSkolem) + // * higher-order type parameters // * parameters of methods - // * type members not visible in the enclosing template - private def isTypeParameterInSig(sym: Symbol, nestedIn: Symbol) = ( - !sym.owner.isTypeParameterOrSkolem && + // * type members not visible in an enclosing template + private def isTypeParameterInSig(sym: Symbol, initialSymbol: Symbol) = ( + !sym.isHigherOrderTypeParameter && sym.isTypeParameterOrSkolem && - (sym isNestedIn nestedIn) + initialSymbol.enclClassChain.exists(sym isNestedIn _) ) + // Ensure every '.' in the generated signature immediately follows // a close angle bracket '>'. Any which do not are replaced with '$'. // This arises due to multiply nested classes in the face of the @@ -274,8 +275,10 @@ abstract class Erasure extends AddInterfaces if (unboundedGenericArrayLevel(tp) == 1) jsig(ObjectClass.tpe) else ARRAY_TAG.toString+(args map jsig).mkString } - else if (isTypeParameterInSig(sym, sym0.enclClass)) + else if (isTypeParameterInSig(sym, sym0)) { + assert(!sym.isAliasType, "Unexpected alias type: " + sym) TVAR_TAG.toString+sym.name+";" + } else if (sym == AnyClass || sym == AnyValClass || sym == SingletonClass) jsig(ObjectClass.tpe) else if (sym == UnitClass) @@ -288,21 +291,23 @@ abstract class Erasure extends AddInterfaces jsig(ObjectClass.tpe) else if (sym.isClass) { val preRebound = pre.baseType(sym.owner) // #2585 - dotCleanup( - ( - if (needsJavaSig(preRebound)) { - val s = jsig(preRebound) - if (s.charAt(0) == 'L') s.substring(0, s.length - 1) + classSigSuffix + traceSig.seq("sym.isClass", Seq(sym.ownerChain, preRebound, sym0.enclClassChain)) { + dotCleanup( + ( + if (needsJavaSig(preRebound)) { + val s = jsig(preRebound) + if (s.charAt(0) == 'L') s.substring(0, s.length - 1) + classSigSuffix + else classSig + } else classSig - } - else classSig - ) + ( - if (args.isEmpty) "" else - "<"+(args map argSig).mkString+">" - ) + ( - ";" + ) + ( + if (args.isEmpty) "" else + "<"+(args map argSig).mkString+">" + ) + ( + ";" + ) ) - ) + } } else jsig(erasure(tp)) case PolyType(tparams, restpe) => @@ -338,13 +343,13 @@ abstract class Erasure extends AddInterfaces else jsig(etp) } } - // traceSig("javaSig", sym0, info) { + traceSig.seq("javaSig", Seq(sym0, info)) { if (needsJavaSig(info)) { try Some(jsig2(true, Nil, info)) catch { case ex: UnknownSig => None } } else None - // } + } } class UnknownSig extends Exception diff --git a/src/compiler/scala/tools/nsc/util/Tracer.scala b/src/compiler/scala/tools/nsc/util/Tracer.scala index c5d3fd3753..17be05a4d6 100644 --- a/src/compiler/scala/tools/nsc/util/Tracer.scala +++ b/src/compiler/scala/tools/nsc/util/Tracer.scala @@ -22,7 +22,7 @@ class Tracer(enabled: () => Boolean) { p(ind("" + x)) x } - def apply[T](name: String, args: Any*)(body: => T): T = { + def seq[T](name: String, args: => Seq[Any])(body: => T): T = { if (enabled()) { p(ind("%s(%s) = {\n".format(name, args mkString ", "))) try indented(pin(body)) @@ -30,6 +30,7 @@ class Tracer(enabled: () => Boolean) { } else body } + def apply[T](name: String, args: Any*)(body: => T): T = seq(name, args.toSeq)(body) } object Tracer { diff --git a/test/files/jvm/JavaInteraction.scala b/test/files/jvm/JavaInteraction.scala index 0381d6aa82..26fbc17e58 100644 --- a/test/files/jvm/JavaInteraction.scala +++ b/test/files/jvm/JavaInteraction.scala @@ -16,7 +16,7 @@ p.x = 5 p.c = java.awt.Color[r=255,g=0,b=0] p.getX() = 5.0 p.getC() = java.awt.Color[r=255,g=0,b=0] - """.trim + "\n" + """.trim def connect() = { val p = new ColoredPoint(5, 7, Color.RED); diff --git a/test/disabled/jvm/t2585.check b/test/files/jvm/t2585.check index e69de29bb2..e69de29bb2 100644 --- a/test/disabled/jvm/t2585.check +++ b/test/files/jvm/t2585.check diff --git a/test/disabled/jvm/t2585/Test.java b/test/files/jvm/t2585/Test.java index 51fe20d81e..51fe20d81e 100644 --- a/test/disabled/jvm/t2585/Test.java +++ b/test/files/jvm/t2585/Test.java diff --git a/test/disabled/jvm/t2585/genericouter.scala b/test/files/jvm/t2585/genericouter.scala index e06aa8101e..e06aa8101e 100644 --- a/test/disabled/jvm/t2585/genericouter.scala +++ b/test/files/jvm/t2585/genericouter.scala |