diff options
Diffstat (limited to 'test/files/run/t6070.scala')
-rw-r--r-- | test/files/run/t6070.scala | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/files/run/t6070.scala b/test/files/run/t6070.scala new file mode 100644 index 0000000000..b6af48ef21 --- /dev/null +++ b/test/files/run/t6070.scala @@ -0,0 +1,36 @@ +abstract class Bomb { + type T + val x: T + + def size(that: T): Int +} + +class StringBomb extends Bomb { + type T = String + val x = "abc" + def size(that: String): Int = that.length +} + +class IntBomb extends Bomb { + type T = Int + val x = 10 + + def size(that: Int) = x + that +} + +case class Mean(var bomb: Bomb) + +object Test extends App { + def foo(x: Mean) = x match { + case Mean(b) => + // BUG: b is assumed to be a stable identifier, but it can actually be mutated + println(b.size({ mutate(); b.x })) + } + + def mutate() { + m.bomb = new IntBomb + } + + val m = Mean(new StringBomb) + foo(m) // should print 3 +}
\ No newline at end of file |