summaryrefslogtreecommitdiff
path: root/test/files/neg/t6258.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2012-08-19 18:25:35 +0200
committerJason Zaugg <jzaugg@gmail.com>2012-08-23 21:41:31 +0200
commitd614ae6e76249ab746a3e78af6e216301ba9bdb4 (patch)
tree48134ee60e9833a82dcde2b6a725e629bec0a428 /test/files/neg/t6258.scala
parent1ab4994990a21c1ea4dadcf15368013d89456ca6 (diff)
downloadscala-d614ae6e76249ab746a3e78af6e216301ba9bdb4.tar.gz
scala-d614ae6e76249ab746a3e78af6e216301ba9bdb4.tar.bz2
scala-d614ae6e76249ab746a3e78af6e216301ba9bdb4.zip
SI-6258 Reject partial funs with undefined param types
This regressed with virtpatmat. With -Xoldpatmat, pattern matching anonymous functions with an expected type of PartialFunction[A, B] are translated to a Function tree, and typed by typedFunction, which issues an error of the parameter types are not fully defined. This commit adds the same check to MatchFunTyper. It doesn't plug the hole in RefChecks#validateVariance (which is reminiscent of SI-3577.) Seems to me that in general one should handle: a) both BoundedWildcardType and WildcardType when in a place that can be called during inference, or b) neither otherwise
Diffstat (limited to 'test/files/neg/t6258.scala')
-rw-r--r--test/files/neg/t6258.scala25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/files/neg/t6258.scala b/test/files/neg/t6258.scala
new file mode 100644
index 0000000000..5046a4750a
--- /dev/null
+++ b/test/files/neg/t6258.scala
@@ -0,0 +1,25 @@
+object Test {
+ val f : PartialFunction[_, Int] = { case a : Int => a } // undefined param
+
+ def foo[A](pf: PartialFunction[A, Int]) {};
+ foo { case a : Int => a } // undefined param
+
+ val g : PartialFunction[Int, _] = { case a : Int => a } // okay
+}
+
+
+// Another variation, seen in the wild with Specs2.
+class X {
+ trait Matcher[-T]
+
+ def bar[T](m: Matcher[T]) = null
+ def bar[T](i: Int) = null
+
+ def foo[T](p: PartialFunction[T, Any]): Matcher[T] = null
+
+ case class M[X](a: X)
+
+ bar[M[Any]] (foo { // undefined param
+ case M(_) => null
+ })
+}