Skip to content

Commit

Permalink
Merge pull request #13489 from dotty-staging/i13487
Browse files Browse the repository at this point in the history
Fix #13487: Unification check in deriving is incorrect
  • Loading branch information
Kordyjan committed Sep 27, 2021
2 parents 164b5d8 + 6fd5bed commit ee8d2ab
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Deriving.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
4 changes: 4 additions & 0 deletions tests/neg/i13487.check
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions tests/neg/i13487.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
trait TC[F[_, _[_]]]
object TC {
def derived[F[_, _[_]]]: TC[F] = ???
}

case class Foo[A](a: A) derives TC // error
6 changes: 6 additions & 0 deletions tests/pos/i13487.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
trait TC[F[_[_], _]]
object TC {
def derived[F[_[_], _]]: TC[F] = ???
}

case class Foo[A](a: A) derives TC

0 comments on commit ee8d2ab

Please sign in to comment.