From 16554c0efe2d09ab3ef760522f0811a964f7ee84 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 11 Dec 2014 18:47:18 +0100 Subject: Fixed #264 - failure to typecheck GADTs The previous scheme derived the right bounds, but then failed to use them because a TypeRef already has a set info (its bounds). Changing the bounds in the symbol by a side effect does not affect that. This is good! But it showed that the previous scheme was too fragile because it used a sneaky side effect when updating the symbol info which failed to propgate into the cached info in TypeRef. We now keep GADT computed bounds separate form the symbol info in a map `gadt` in the current context. --- tests/pos/i0268.scala | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tests/pos/i0268.scala (limited to 'tests/pos/i0268.scala') diff --git a/tests/pos/i0268.scala b/tests/pos/i0268.scala new file mode 100644 index 000000000..6ac0c5c90 --- /dev/null +++ b/tests/pos/i0268.scala @@ -0,0 +1,15 @@ +package typespatmat + +sealed trait Box2[T] +final case class Int2(x: Int) extends Box2[Int] +final case class Str2(x: String) + extends Box2[String] +final case class Gen[T](x: T) extends Box2[T] + +object Box2 { + def double2[T](x: Box2[T]): T = x match { + case Int2(i) => i * 2 + case Str2(s) => s + s + case Gen(x) => x + } +} -- cgit v1.2.3