summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2012-10-30 14:30:55 -0700
committerAdriaan Moors <adriaan.moors@typesafe.com>2012-10-30 14:30:55 -0700
commitae0171321b94c42a36d0987503450ce2657fd516 (patch)
tree40014ec529231ae510ffadefb9724d702776c958 /test
parent2c554249fd8e99286134b217027b6e3cb2c92d77 (diff)
parentf30f97273aa40600f0f8d7c3e96d0ab3e0eed318 (diff)
downloadscala-ae0171321b94c42a36d0987503450ce2657fd516.tar.gz
scala-ae0171321b94c42a36d0987503450ce2657fd516.tar.bz2
scala-ae0171321b94c42a36d0987503450ce2657fd516.zip
Merge pull request #1530 from retronym/ticket/6575-2
SI-6575 Plug inference leak of AbstractPartialFunction
Diffstat (limited to 'test')
-rw-r--r--test/files/pos/t6575a.scala15
-rw-r--r--test/files/pos/t6575b.scala17
2 files changed, 32 insertions, 0 deletions
diff --git a/test/files/pos/t6575a.scala b/test/files/pos/t6575a.scala
new file mode 100644
index 0000000000..f128714dab
--- /dev/null
+++ b/test/files/pos/t6575a.scala
@@ -0,0 +1,15 @@
+trait X { def foo: PartialFunction[Int, Int] }
+
+trait Y extends X {
+ // Inferred type was AbstractPartialFunction[Int, Int] with Serializable
+ abstract override def foo = { case i => super.foo(i) * 2 }
+}
+trait Z extends X {
+ // ditto
+ abstract override def foo = { case i => super.foo(i) + 3 }
+}
+
+trait Comb extends Y with Z {
+ // ... which led to a type error here.
+ abstract override def foo: PartialFunction[Int, Int] = { case i => super.foo(i) - 2 }
+}
diff --git a/test/files/pos/t6575b.scala b/test/files/pos/t6575b.scala
new file mode 100644
index 0000000000..d3e58b2a16
--- /dev/null
+++ b/test/files/pos/t6575b.scala
@@ -0,0 +1,17 @@
+// inferred types were okay here as Function nodes aren't
+// translated into anoymous subclasses of AbstractFunctionN
+// until after the typer.
+//
+// So this test is just confirmation.
+trait X { def foo: Function1[Int, Int] }
+
+trait Y extends X {
+ abstract override def foo = { case i => super.foo(i) * 2 }
+}
+trait Z extends X {
+ abstract override def foo = { case i => super.foo(i) + 3 }
+}
+
+trait Comb extends Y with Z {
+ abstract override def foo: Function1[Int, Int] = { case i => super.foo(i) - 2 }
+}