Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SI-6624 set info of case pattern binder to help find case field acces…
…sors 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
- Loading branch information
Showing
2 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(_) => | ||
} | ||
} |