summaryrefslogtreecommitdiff
path: root/test/files/neg/t5120.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2011-11-01 17:16:51 +0000
committerMartin Odersky <odersky@gmail.com>2011-11-01 17:16:51 +0000
commitb7b81ca286b1f426cd19befd50fbc513bb82282f (patch)
tree1008c7594c42995b7758b2bb09f87134ac98b2d1 /test/files/neg/t5120.scala
parent69b3cd50923b3f495f1e421e8a4ac505044f3c40 (diff)
downloadscala-b7b81ca286b1f426cd19befd50fbc513bb82282f.tar.gz
scala-b7b81ca286b1f426cd19befd50fbc513bb82282f.tar.bz2
scala-b7b81ca286b1f426cd19befd50fbc513bb82282f.zip
Fixed type unsoundness problem in t5120 and als...
Fixed type unsoundness problem in t5120 and also discovered by roman.kalukiewicz@gmail.com. Fix should be refined further, as I am not convinced we are quite done yet. Review by moors.
Diffstat (limited to 'test/files/neg/t5120.scala')
-rw-r--r--test/files/neg/t5120.scala29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/files/neg/t5120.scala b/test/files/neg/t5120.scala
new file mode 100644
index 0000000000..f28b2cfb4f
--- /dev/null
+++ b/test/files/neg/t5120.scala
@@ -0,0 +1,29 @@
+class Cell[T](x0: T) {
+ type U = T
+ var x1: U = x0
+}
+
+object Test {
+ val str: Cell[String] = new Cell("a")
+ val other: Cell[Int] = new Cell(0)
+
+ def main(args: Array[String]): Unit = {
+ List(str, other) foreach (_.x1 = new AnyRef)
+ str.x1.length
+ }
+}
+// another way demonstrating the same underlying problem, as reported by roman kalukiewicz
+
+class Holder[_T](_f1 : _T, _f2 : _T) {
+ type T = _T
+ var f1 : T = _f1
+ var f2 : T = _f2
+}
+object Test2 {
+ val str = new Holder("t1", "t2")
+ val num = new Holder(1, 2)
+ List(str, num).foreach(h => h.f1 = new Thread())
+ def main(args: Array[String]) {
+ println(str.f1)
+ }
+}