Skip to content
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

Fix upper bound constraints, that are higher-kinded #16744

Merged
merged 1 commit into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1338,8 +1338,11 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
}
} || tryLiftedToThis2

case _: TypeVar =>
recur(tp1, tp2.superType)
case tv: TypeVar =>
if tv.isInstantiated then
recur(tp1, tp2.superType)
else
compareAppliedType2(tp2, tv.origin, args2)
case tycon2: AnnotatedType if !tycon2.isRefining =>
recur(tp1, tp2.superType)
case tycon2: AppliedType =>
Expand Down
19 changes: 19 additions & 0 deletions tests/pos/i12478.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
sealed trait Foo[T]

object Foo:
case class Bar[F[_]](fu: List[F[Unit]]) extends Foo[F[Unit]]

class Test:
def id1[T1](foo1: Foo[T1]): Foo[T1] = foo1 match
case Foo.Bar(fu) =>
Foo.Bar(fu)

def id2[T2](foo2: Foo[T2]): Foo[T2] = foo2 match
case bar2 @ (_: Foo.Bar[f]) =>
val fu2 = bar2.fu
Foo.Bar(fu2)

def id3[T3](foo3: Foo[T3]): Foo[T3] = foo3 match
case bar3 @ Foo.Bar(_) =>
val fu3 = bar3.fu
Foo.Bar(fu3)