From 32c57329a6cb7ff1fa479a1fce884b8166f3fc50 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Thu, 15 Nov 2012 16:48:03 -0800 Subject: SI-6624 set info of case pattern binder to help find case field accessors sometimes the type checker infers a weird type for a sub-pattern of a case class/extractor pattern this confuses the pattern matcher and it can't find the case field accessors for the sub-pattern use the expected argument type of the extractor corresponding to the case class that we're matching as the info for the sub-pattern binder -- this type more readily admits querying its caseFieldAccessors --- test/files/pos/t6624.scala | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 test/files/pos/t6624.scala (limited to 'test') diff --git a/test/files/pos/t6624.scala b/test/files/pos/t6624.scala new file mode 100644 index 0000000000..1a92b92d53 --- /dev/null +++ b/test/files/pos/t6624.scala @@ -0,0 +1,28 @@ +sealed trait KList[+M[_]] + +case class KCons[M[_], +T <: KList[M]]( + tail: T +) extends KList[M] + +case class KNil[M[_]]() extends KList[M] + +object Test { + val klist: KCons[Option, KCons[Option, KCons[Option, KNil[Nothing]]]] = ??? + + // crashes with + // "Exception in thread "main" scala.reflect.internal.Types$TypeError: value _1 is not a member + // of KCons[Option,KCons[Option,KNil[Nothing]]]" + klist match { + case KCons(KCons(KCons(_))) => + } + + // fails with a similar message as an error, rather than a crash. + klist match { + case KCons(KCons(_)) => + } + + // succeeds + klist match { + case KCons(_) => + } +} \ No newline at end of file -- cgit v1.2.3