summaryrefslogtreecommitdiff
path: root/test/files/run/value-class-partial-func-depmet.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-11-23 09:41:07 +0100
committerJason Zaugg <jzaugg@gmail.com>2013-11-23 09:51:22 +0100
commitcb37548ef85d471951867b9f8a97cb9b9820fc66 (patch)
tree26a89234c96025763bf6666f42db055786425a8b /test/files/run/value-class-partial-func-depmet.scala
parentd7d63e93f35c692b26e95db1b02d758723dde18d (diff)
downloadscala-cb37548ef85d471951867b9f8a97cb9b9820fc66.tar.gz
scala-cb37548ef85d471951867b9f8a97cb9b9820fc66.tar.bz2
scala-cb37548ef85d471951867b9f8a97cb9b9820fc66.zip
Symbol substutition must consider ClassInfoType#parents
An upcoming change to uncurry, in which I plan to make substitution of `lambda params -> apply method params` requires that I first to fix a problem in symbol substition. This situation can arise when the body of this definition: def owner1(a: A) = { class C extends M[a.B] } is transplanted into a new owner that has a different symbol for `a`. I speculated that value classes might also be prone to the fact that symbol substitution neglected `ClassInfoType#parents`. We can test change with Value Classes: Partial Functions that are dependent on value class param type used to fail with a spurious overriding error, now they work correctly.
Diffstat (limited to 'test/files/run/value-class-partial-func-depmet.scala')
-rw-r--r--test/files/run/value-class-partial-func-depmet.scala24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/files/run/value-class-partial-func-depmet.scala b/test/files/run/value-class-partial-func-depmet.scala
new file mode 100644
index 0000000000..12ff64ed36
--- /dev/null
+++ b/test/files/run/value-class-partial-func-depmet.scala
@@ -0,0 +1,24 @@
+class C
+class A { class C }
+
+object Test {
+ def main(args: Array[String]) {
+ val a = new A
+
+ new VC("").foo(a)
+ }
+}
+
+class VC(val a: Any) extends AnyVal {
+ def foo(a: A) = {
+ val pf: PartialFunction[a.C, Any] = { case x => x }
+ (pf: PartialFunction[Null, Any]).isDefinedAt(null)
+ }
+}
+
+// 2.11.0-M6
+// test/files/run/value-class-partial-func-depmet.scala:14: error: overriding method applyOrElse in trait PartialFunction of type [A1 <: a.C, B1 >: Any](x: A1, default: A1 => B1)B1;
+// method applyOrElse has incompatible type
+// val pf: PartialFunction[a.C, Any] = { case x => x }
+// ^
+// one error found