summaryrefslogtreecommitdiff
path: root/test/files/neg/t5120.scala
blob: 0df67bc09bec3ddcd41e3873251bc8e922efebbe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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)
  }
}