-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add missing case to TypeComparer #3713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -475,12 +475,17 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { | |
isSubType(tp1.resType, tp2.resType.subst(tp2, tp1)) | ||
finally comparedTypeLambdas = saved | ||
case _ => | ||
if (!tp1.isHK) { | ||
tp2 match { | ||
case EtaExpansion(tycon2) if tycon2.symbol.isClass => | ||
return isSubType(tp1, tycon2) | ||
case _ => | ||
} | ||
if (tp1.isHK) { | ||
val tparams1 = tp1.typeParams | ||
return isSubType( | ||
HKTypeLambda.fromParams(tparams1, tp1.appliedTo(tparams1.map(_.paramRef))), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be written There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. EtaExpansion only works for class type constructors. I tried to change that, but it would be quite involved, so I thought it was simpler to write the code directly here. |
||
tp2 | ||
) | ||
} | ||
else tp2 match { | ||
case EtaExpansion(tycon2) if tycon2.symbol.isClass => | ||
return isSubType(tp1, tycon2) | ||
case _ => | ||
} | ||
fourthTry(tp1, tp2) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class Foo[+X[_]] { | ||
// OK | ||
def foo1[Y[_]](right: Foo[Y]): Foo[Y] = right | ||
// OK | ||
def foo2[Y[_]](right: Foo[[T] => Y[T]]): Foo[Y] = right | ||
// OK | ||
def foo3[Y[_]](right: Foo[[T] => Y[T]]): Foo[[T] => Y[T]] = right | ||
// Error: | ||
// found: Foo[Y](right) | ||
// required: Foo[Y] | ||
def foo4[Y[_]](right: Foo[Y]): Foo[[T] => Y[T]] = right | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
object App { | ||
def main(args: Array[String]): Unit = { | ||
trait ModuleSig { | ||
type F[_] | ||
type Type = F | ||
|
||
def subst[F[_[_]]](fa: F[List]): F[Type] | ||
} | ||
val Module: ModuleSig = new ModuleSig { | ||
type F[+A] = List[A] | ||
|
||
def subst[FF[_[_]]](fa: FF[List]): FF[Type] = fa | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any idea why we manage to hit this assertion in the IDE?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea, I am afraid.