From 03a8f644c2b99073c2cca79e4d2c01539fa3391a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pa=C5=82ka?= Date: Wed, 22 Mar 2023 13:09:33 +0100 Subject: [PATCH] Improve subtyping check for not yet eta-expanded higher kinded types --- .../src/dotty/tools/dotc/core/TypeComparer.scala | 2 +- tests/pos/i16183/Lib_1.scala | 14 ++++++++++++++ tests/pos/i16183/Test_2.scala | 6 ++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i16183/Lib_1.scala create mode 100644 tests/pos/i16183/Test_2.scala diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index 9dda18c72f26..ac6a6b9481d8 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -580,7 +580,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling val base = nonExprBaseType(tp1, cls2) if (base.typeSymbol == cls2) return true } - else if tp1.isLambdaSub && !tp1.isAnyKind then + else if tp1.typeParams.nonEmpty && !tp1.isAnyKind then return recur(tp1, EtaExpansion(tp2)) fourthTry } diff --git a/tests/pos/i16183/Lib_1.scala b/tests/pos/i16183/Lib_1.scala new file mode 100644 index 000000000000..824af18e1d40 --- /dev/null +++ b/tests/pos/i16183/Lib_1.scala @@ -0,0 +1,14 @@ +package pkg + +trait Foo1[A] +trait Foo2[A] extends Foo1[A] + +trait Bar[F[_]] +object Bar { + implicit val bar: Bar[pkg.Foo2] = ??? +} + +trait Qux +object Qux { + implicit def qux[F[_]](implicit bar: Bar[F]): F[Qux] = ??? +} \ No newline at end of file diff --git a/tests/pos/i16183/Test_2.scala b/tests/pos/i16183/Test_2.scala new file mode 100644 index 000000000000..c8c5cbed838c --- /dev/null +++ b/tests/pos/i16183/Test_2.scala @@ -0,0 +1,6 @@ +import pkg._ + +object Test { + implicitly[Foo2[Qux]] + implicitly[Foo1[Qux]] +} \ No newline at end of file