diff options
Diffstat (limited to 'test/files/neg')
-rw-r--r-- | test/files/neg/t3015.check | 6 | ||||
-rw-r--r-- | test/files/neg/t5120.check | 12 | ||||
-rw-r--r-- | test/files/neg/t5120.scala | 29 |
3 files changed, 44 insertions, 3 deletions
diff --git a/test/files/neg/t3015.check b/test/files/neg/t3015.check index 6095efc6a7..0b394e23d6 100644 --- a/test/files/neg/t3015.check +++ b/test/files/neg/t3015.check @@ -1,11 +1,11 @@ t3015.scala:7: error: scrutinee is incompatible with pattern type; - found : _$1 where type _$1 + found : _$1 where type +_$1 required: String val b(foo) = "foo" ^ t3015.scala:7: error: type mismatch; - found : _$1(in value foo) where type _$1(in value foo) <: String - required: (some other)_$1(in value foo) where type (some other)_$1(in value foo) + found : String with _$1(in object Test) where type +_$1(in object Test) + required: (some other)_$1(in object Test) where type +(some other)_$1(in object Test) val b(foo) = "foo" ^ two errors found diff --git a/test/files/neg/t5120.check b/test/files/neg/t5120.check new file mode 100644 index 0000000000..34d4ebde31 --- /dev/null +++ b/test/files/neg/t5120.check @@ -0,0 +1,12 @@ +t5120.scala:11: error: type mismatch; + found : Object + required: _1 + List(str, other) foreach (_.x1 = new AnyRef) + ^ +t5120.scala:25: error: type mismatch; + found : Thread + required: h.T + (which expands to) _2 + List(str, num).foreach(h => h.f1 = new Thread()) + ^ +two errors found 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) + } +} |