diff options
Diffstat (limited to 'test/files/pos')
-rw-r--r-- | test/files/pos/gadts2.scala | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/files/pos/gadts2.scala b/test/files/pos/gadts2.scala new file mode 100644 index 0000000000..ca905c572a --- /dev/null +++ b/test/files/pos/gadts2.scala @@ -0,0 +1,26 @@ +object Test{ + +abstract class Number +case class Int(n: int) extends Number +case class Double(d: double) extends Number + +trait Term[+a] +case class Cell[a](var x: a) extends Term[a] +final case class NumTerm(val n: Number) extends Term[Number] + + +def f[a](t:Term[a], c:Cell[a]): unit = + t match { + case NumTerm(n) => c.x = Double(1.0) + } + + +val x:Term[Number] = NumTerm(Int(5)) + +def main(args: Array[String]): unit = { + val cell = Cell[Number](Int(6)) + Console.println(cell) + f[Number](new NumTerm(Int(5)), cell) + Console.println(cell) +} +} |