Skip to content

Fix #13487: Unification check in deriving is incorrect #13489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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