Skip to content

Commit fb7a058

Browse files
committed
When checking tp1 <:< tycon2[args2], widen tp1 to reveal application
Fixes #11499 (see the discussion there for details on what happened in the test case before this change).
1 parent 000a541 commit fb7a058

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
10031003
/** True if `tp1` and `tp2` have compatible type constructors and their
10041004
* corresponding arguments are subtypes relative to their variance (see `isSubArgs`).
10051005
*/
1006-
def isMatchingApply(tp1: Type): Boolean = tp1 match {
1006+
def isMatchingApply(tp1: Type): Boolean = tp1.widen match {
10071007
case tp1 @ AppliedType(tycon1, args1) =>
10081008
// We intentionally do not automatically dealias `tycon1` or `tycon2` here.
10091009
// `TypeApplications#appliedTo` already takes care of dealiasing type

tests/pos/i11499.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
trait Functor[F[_]]
2+
3+
object data {
4+
5+
type OptionT[F[_], A] = F[Option[A]]
6+
7+
def fold[F[_], A, B](value: OptionT[F, A])(f: Functor[F]): F[B] = ???
8+
9+
def cata[F[_], A, B](value: OptionT[F, A])(f: Functor[F]): F[B] =
10+
fold(value)(f) // error
11+
}

0 commit comments

Comments
 (0)