Skip to content

Commit ee8d2ab

Browse files
authored
Merge pull request #13489 from dotty-staging/i13487
Fix #13487: Unification check in deriving is incorrect
2 parents 164b5d8 + 6fd5bed commit ee8d2ab

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

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

+1-1
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

+4
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

+6
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

+6
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)