summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@epfl.ch>2010-06-29 12:32:45 +0000
committerLukas Rytz <lukas.rytz@epfl.ch>2010-06-29 12:32:45 +0000
commit1067f5f55ca0de0035fee3d0179203801f0b4b87 (patch)
treea76deb0da297f758321676fd9e80b39a2b3b46a9
parentbf639030734f9eed8c07342fb30e5d4fc94d850b (diff)
downloadscala-1067f5f55ca0de0035fee3d0179203801f0b4b87.tar.gz
scala-1067f5f55ca0de0035fee3d0179203801f0b4b87.tar.bz2
scala-1067f5f55ca0de0035fee3d0179203801f0b4b87.zip
close #2413.
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala12
-rw-r--r--test/files/pos/t2413/TestJava.java7
-rw-r--r--test/files/pos/t2413/TestScalac.scala23
3 files changed, 41 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
index ea2cfd6204..3dfbbbb77f 100644
--- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
@@ -272,12 +272,22 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT
case _ => Nil
}
+ // fix for #2413
+ object javaToScalaRepeated extends TypeMap {
+ def apply(tp: Type): Type = tp match {
+ case tp @ TypeRef(_, _, List(arg)) if tp.typeSymbol == definitions.JavaRepeatedParamClass =>
+ appliedType(definitions.RepeatedParamClass.typeConstructor, List(arg))
+ case _ =>
+ mapOver(tp)
+ }
+ }
+
assert(clazz != NoSymbol, sym)
if (settings.debug.value) log("Decided for host class: " + clazz)
val accName = nme.protName(sym.originalName)
val hasArgs = sym.tpe.paramTypes != Nil
- val memberType = sym.tpe // transform(sym.tpe)
+ val memberType = javaToScalaRepeated(sym.tpe) // transform(sym.tpe)
// if the result type depends on the this type of an enclosing class, the accessor
// has to take an object of exactly this type, otherwise it's more general
diff --git a/test/files/pos/t2413/TestJava.java b/test/files/pos/t2413/TestJava.java
new file mode 100644
index 0000000000..252c01fbc0
--- /dev/null
+++ b/test/files/pos/t2413/TestJava.java
@@ -0,0 +1,7 @@
+package pack;
+
+public class TestJava {
+ protected String repeatParam(String ... items) {
+ return "nothing";
+ }
+}
diff --git a/test/files/pos/t2413/TestScalac.scala b/test/files/pos/t2413/TestScalac.scala
new file mode 100644
index 0000000000..098e852dd7
--- /dev/null
+++ b/test/files/pos/t2413/TestScalac.scala
@@ -0,0 +1,23 @@
+import pack.TestJava
+
+class Foo extends TestJava {
+
+ // THIS METHOD YIELDS TO CRASH
+/* def foomethod : Option[String] => Unit = {
+ case None =>
+ val path = repeatParam("s","a","b","c")
+ ()
+ case Some(error) =>
+ ()
+ }
+
+ // THIS IS OK
+ def foomethod2 : String = repeatParam("s","a");
+
+ // THIS IS OK
+ val aVal = repeatParam("1","2","3") */
+
+ // THIS YIELDS TO CRASH
+ for (a <- 1 to 4 ; anotherVal = repeatParam("1","2","3"))
+ yield anotherVal
+}