diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-11-15 16:48:03 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-11-16 18:08:53 -0800 |
commit | 32c57329a6cb7ff1fa479a1fce884b8166f3fc50 (patch) | |
tree | bf692f26236b210a4280c9cb1dbd20b221b1fd8c /test | |
parent | ea87ecbe818f7445156d6c2548e429a8ca54595d (diff) | |
download | scala-32c57329a6cb7ff1fa479a1fce884b8166f3fc50.tar.gz scala-32c57329a6cb7ff1fa479a1fce884b8166f3fc50.tar.bz2 scala-32c57329a6cb7ff1fa479a1fce884b8166f3fc50.zip |
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
Diffstat (limited to 'test')
-rw-r--r-- | test/files/pos/t6624.scala | 28 |
1 files changed, 28 insertions, 0 deletions
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 |