diff --git a/compiler/src/dotty/tools/dotc/typer/Deriving.scala b/compiler/src/dotty/tools/dotc/typer/Deriving.scala index 269924c21114..a8de83664001 100644 --- a/compiler/src/dotty/tools/dotc/typer/Deriving.scala +++ b/compiler/src/dotty/tools/dotc/typer/Deriving.scala @@ -160,7 +160,7 @@ trait Deriving { val clsParamInfos = clsType.typeParams val clsArity = clsParamInfos.length val alignedClsParamInfos = clsParamInfos.takeRight(instanceArity) - val alignedTypeClassParamInfos = typeClassParamInfos.take(alignedClsParamInfos.length) + val alignedTypeClassParamInfos = typeClassParamInfos.takeRight(alignedClsParamInfos.length) if ((instanceArity == clsArity || instanceArity > 0) && sameParamKinds(alignedClsParamInfos, alignedTypeClassParamInfos)) { diff --git a/tests/neg/i13487.check b/tests/neg/i13487.check new file mode 100644 index 000000000000..486124661ea4 --- /dev/null +++ b/tests/neg/i13487.check @@ -0,0 +1,4 @@ +-- Error: tests/neg/i13487.scala:6:32 ---------------------------------------------------------------------------------- +6 |case class Foo[A](a: A) derives TC // error + | ^^ + | Foo cannot be unified with the type argument of TC diff --git a/tests/neg/i13487.scala b/tests/neg/i13487.scala new file mode 100644 index 000000000000..e06258087846 --- /dev/null +++ b/tests/neg/i13487.scala @@ -0,0 +1,6 @@ +trait TC[F[_, _[_]]] +object TC { + def derived[F[_, _[_]]]: TC[F] = ??? +} + +case class Foo[A](a: A) derives TC // error diff --git a/tests/pos/i13487.scala b/tests/pos/i13487.scala new file mode 100644 index 000000000000..ce08513f3c25 --- /dev/null +++ b/tests/pos/i13487.scala @@ -0,0 +1,6 @@ +trait TC[F[_[_], _]] +object TC { + def derived[F[_[_], _]]: TC[F] = ??? +} + +case class Foo[A](a: A) derives TC