Skip to content

Commit 6fd5bed

Browse files
committed
Fix #13487: Unification check in deriving is incorrect
1 parent 8e92478 commit 6fd5bed

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Deriving.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ trait Deriving {
160160
val clsParamInfos = clsType.typeParams
161161
val clsArity = clsParamInfos.length
162162
val alignedClsParamInfos = clsParamInfos.takeRight(instanceArity)
163-
val alignedTypeClassParamInfos = typeClassParamInfos.take(alignedClsParamInfos.length)
163+
val alignedTypeClassParamInfos = typeClassParamInfos.takeRight(alignedClsParamInfos.length)
164164

165165

166166
if ((instanceArity == clsArity || instanceArity > 0) && sameParamKinds(alignedClsParamInfos, alignedTypeClassParamInfos)) {

tests/neg/i13487.check

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- Error: tests/neg/i13487.scala:6:32 ----------------------------------------------------------------------------------
2+
6 |case class Foo[A](a: A) derives TC // error
3+
| ^^
4+
| Foo cannot be unified with the type argument of TC

tests/neg/i13487.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
trait TC[F[_, _[_]]]
2+
object TC {
3+
def derived[F[_, _[_]]]: TC[F] = ???
4+
}
5+
6+
case class Foo[A](a: A) derives TC // error

tests/pos/i13487.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
trait TC[F[_[_], _]]
2+
object TC {
3+
def derived[F[_[_], _]]: TC[F] = ???
4+
}
5+
6+
case class Foo[A](a: A) derives TC

0 commit comments

Comments
 (0)