summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/reflect/internal/Types.scala12
-rw-r--r--test/files/neg/t5067.check6
-rw-r--r--test/files/neg/t5067.scala4
3 files changed, 17 insertions, 5 deletions
diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala
index a7a5efe21a..c313f079ae 100644
--- a/src/compiler/scala/reflect/internal/Types.scala
+++ b/src/compiler/scala/reflect/internal/Types.scala
@@ -2030,12 +2030,14 @@ A type's typeSymbol should never be inspected directly.
if (isFunctionType(this)) {
val targs = normalize.typeArgs
// Aesthetics: printing Function1 as T => R rather than (T) => R
- val paramlist = targs.init match {
- case Nil => "()"
- case x :: Nil => "" + x
- case xs => xs.mkString("(", ", ", ")")
+ // ...but only if it's not a tuple, so ((T1, T2)) => R is distinguishable
+ // from (T1, T2) => R.
+ targs match {
+ case in :: out :: Nil if !isTupleTypeOrSubtype(in) =>
+ "" + in + " => " + out
+ case xs =>
+ xs.init.mkString("(", ", ", ")") + " => " + xs.last
}
- paramlist + " => " + targs.last
}
else if (isTupleTypeOrSubtype(this))
normalize.typeArgs.mkString("(", ", ", if (hasLength(normalize.typeArgs, 1)) ",)" else ")")
diff --git a/test/files/neg/t5067.check b/test/files/neg/t5067.check
new file mode 100644
index 0000000000..32491766d7
--- /dev/null
+++ b/test/files/neg/t5067.check
@@ -0,0 +1,6 @@
+t5067.scala:3: error: type mismatch;
+ found : ((Int, Int)) => Int
+ required: (Int, Int) => Int
+ override def tupled: (Int, Int) => Int = super.tupled
+ ^
+one error found
diff --git a/test/files/neg/t5067.scala b/test/files/neg/t5067.scala
new file mode 100644
index 0000000000..f8235c0e83
--- /dev/null
+++ b/test/files/neg/t5067.scala
@@ -0,0 +1,4 @@
+class Foo extends Function2[Int, Int, Int] {
+ def apply(x: Int, y: Int) = x + y
+ override def tupled: (Int, Int) => Int = super.tupled
+}