diff options
author | Paul Phillips <paulp@improving.org> | 2011-03-07 11:22:44 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-03-07 11:22:44 +0000 |
commit | ca392540e36bf1fc52350901b3faf5bc08f4175c (patch) | |
tree | 17fef00d7ae2c028cad1b72d02b85b657341c483 | |
parent | 2edab8991bc07ce0eecb3a85d8317e31f98df840 (diff) | |
download | scala-ca392540e36bf1fc52350901b3faf5bc08f4175c.tar.gz scala-ca392540e36bf1fc52350901b3faf5bc08f4175c.tar.bz2 scala-ca392540e36bf1fc52350901b3faf5bc08f4175c.zip |
More signature work arising from actually looki...
More signature work arising from actually looking at the signatures.
Slightly improved the coverage of the tests. No review.
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/Erasure.scala | 10 | ||||
-rw-r--r-- | src/partest/scala/tools/partest/ReplTest.scala | 10 | ||||
-rw-r--r-- | test/files/run/bug4238/J_1.java | 14 | ||||
-rw-r--r-- | test/files/run/bug4291.scala | 10 |
4 files changed, 32 insertions, 12 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index a2ab678e36..7030b70082 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -203,12 +203,16 @@ abstract class Erasure extends AddInterfaces // only refer to type params that will actually make it into the sig, this excludes: // * higher-order type parameters - // * parameters of methods + // * type parameters appearing in method parameters // * type members not visible in an enclosing template private def isTypeParameterInSig(sym: Symbol, initialSymbol: Symbol) = ( !sym.isHigherOrderTypeParameter && - sym.isTypeParameterOrSkolem && - initialSymbol.enclClassChain.exists(sym isNestedIn _) + sym.isTypeParameterOrSkolem && ( + (initialSymbol.enclClassChain.exists(sym isNestedIn _)) || + traceSig.seq("isMethod", Seq(initialSymbol, initialSymbol.typeParams)) { + (initialSymbol.isMethod && initialSymbol.typeParams.contains(sym)) + } + ) ) // Ensure every '.' in the generated signature immediately follows diff --git a/src/partest/scala/tools/partest/ReplTest.scala b/src/partest/scala/tools/partest/ReplTest.scala index 232d605bb0..b7bd8efcf4 100644 --- a/src/partest/scala/tools/partest/ReplTest.scala +++ b/src/partest/scala/tools/partest/ReplTest.scala @@ -17,3 +17,13 @@ abstract class ReplTest extends App { show() } + +trait SigTest { + def returnType[T: Manifest](methodName: String) = ( + classManifest[T].erasure.getMethods + . filter (x => !x.isBridge && x.getName == methodName) + . map (_.getGenericReturnType.toString) + ) + def show[T: Manifest](methodName: String) = + println(manifest[T].erasure.getName +: returnType[T](methodName).distinct mkString " ") +} diff --git a/test/files/run/bug4238/J_1.java b/test/files/run/bug4238/J_1.java index 1cc8058385..47a9c21000 100644 --- a/test/files/run/bug4238/J_1.java +++ b/test/files/run/bug4238/J_1.java @@ -1,4 +1,16 @@ +import scala.*; + class J_1 { - scala.collection.mutable.HashMap<String, String> x = + scala.collection.mutable.HashMap<String, String> map = new scala.collection.mutable.HashMap<String, String>(); + + Function1<Tuple2<String, String>, Integer> f = + new scala.runtime.AbstractFunction1<Tuple2<String, String>, Integer>() { + public Integer apply(Tuple2<String, String> s) { + return s._1().length(); + } + }; + + scala.collection.Seq<Integer> counts = + map.groupBy(f).keys().toList(); } diff --git a/test/files/run/bug4291.scala b/test/files/run/bug4291.scala index 3eeaa88be0..6053c7ac6a 100644 --- a/test/files/run/bug4291.scala +++ b/test/files/run/bug4291.scala @@ -1,12 +1,6 @@ -object Test { - def returnType[T: Manifest](methodName: String) = ( - classManifest[T].erasure.getMethods - . filter (x => !x.isBridge && x.getName == methodName) - . map (_.getGenericReturnType.toString) - ) - def show[T: Manifest](methodName: String) = - println(manifest[T].erasure.getName +: returnType[T](methodName).distinct mkString " ") +import scala.tools.partest._ +object Test extends SigTest { def main(args: Array[String]): Unit = { show[List[_]]("apply") show[Option[_]]("get") |