summaryrefslogtreecommitdiff
path: root/test/files/neg/t963.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-05-03 23:11:05 -0700
committerPaul Phillips <paulp@improving.org>2012-05-04 01:22:23 -0700
commit01f6ed8e22d02811fe62b9183d9f84bdda5ede4b (patch)
tree6cc9b5a4847ba7940ddd8313a1a906b06024b5bf /test/files/neg/t963.scala
parentaad6deae7204a7fc95b59ede61b188bb62f51188 (diff)
downloadscala-01f6ed8e22d02811fe62b9183d9f84bdda5ede4b.tar.gz
scala-01f6ed8e22d02811fe62b9183d9f84bdda5ede4b.tar.bz2
scala-01f6ed8e22d02811fe62b9183d9f84bdda5ede4b.zip
Fix for one of the oldest open soundness bugs.
Closes SI-963, since it was one of my random 30 it won the prize. The trick after adding the stability check (which has been sitting there commented out for 3+ years) was that implicit search depended on the wrongness, because memberWildcardType would create scopes with members of the form ?{ val name: tp } And since a def shouldn't match that, fixing it broke everything until I flipped it around: memberWildcardType should be seeking ?{ def name: tp } It could also search for a mutable value: the relevant quality is that it not be stable so it doesn't have a tighter type than the members it hopes to match.
Diffstat (limited to 'test/files/neg/t963.scala')
-rw-r--r--test/files/neg/t963.scala18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/files/neg/t963.scala b/test/files/neg/t963.scala
new file mode 100644
index 0000000000..0cc2034299
--- /dev/null
+++ b/test/files/neg/t963.scala
@@ -0,0 +1,18 @@
+import scala.util.Random
+
+// Only y1 (val/val) should actually compile.
+object Test {
+ val r = new Random()
+
+ val y1 : { val x : java.lang.Integer } = new { val x = new java.lang.Integer(r.nextInt) }
+ val w1 : y1.x.type = y1.x
+
+ val y2 : { val x : java.lang.Integer } = new { def x = new java.lang.Integer(r.nextInt) }
+ val w2 : y2.x.type = y2.x
+
+ val y3 : { def x : java.lang.Integer } = new { val x = new java.lang.Integer(r.nextInt) }
+ val w3 : y3.x.type = y3.x
+
+ val y4 : { def x : java.lang.Integer } = new { def x = new java.lang.Integer(r.nextInt) }
+ val w4 : y4.x.type = y4.x
+}