Skip to content
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

Regression in Scala 3.5.0-RC1 related to match types in using parameters #20469

Closed
mrdziuban opened this issue May 24, 2024 · 1 comment
Closed
Labels
itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label

Comments

@mrdziuban
Copy link

mrdziuban commented May 24, 2024

Compiler version

3.5.0-RC1, the issue is not present in 3.4.2

Minimized code

case class Foo[A]()
case class Bar[A]()

type TestMatch[F[_]] = [A] =>> F[Unit] match {
  case Foo[Unit] => Bar[A]
}

trait TestTC1[A]
object TestTC1 {
  given inst: TestTC1[Bar[Int]] = new TestTC1[Bar[Int]] {}
}

trait TestTC2[A]
object TestTC2 {
  given inst[F[_], A](using tc1: TestTC1[TestMatch[F][A]]): TestTC2[F[A]] = new TestTC2[F[A]] {}
}

summon[TestTC2[TestMatch[Foo][Int]]]

Output

-- [E172] Type Error: ----------------------------------------------------------
1 |summon[TestTC2[TestMatch[Foo][Int]]]
  |                                    ^
  |No given instance of type TestTC2[TestMatch[Foo][Int]] was found for parameter x of method summon in object Predef.
  |I found:
  |
  |    TestTC2.inst[TestMatch[Foo], Int](
  |      /* missing */summon[TestTC1[TestMatch[TestMatch[Foo]][Int]]])
  |
  |But no implicit values were found that match type TestTC1[TestMatch[TestMatch[Foo]][Int]].

Expectation

The implicit search should discover TestTC1.inst as a valid candidate for the using parameter of TestTC2.inst

@mrdziuban mrdziuban added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels May 24, 2024
@mrdziuban
Copy link
Author

Sorry, never mind on this one, the summon part of my reproduction code above doesn't make sense. It's correct that there's no instance of TestTC1[TestMatch[TestMatch[Foo]][Int]] because that would be a TestTC1[TestMatch[Bar][Int]], and there's no case in the match type for Bar

There is some issue in my codebase similar to this, but I'm going to close this until I've minimized it. In the meantime, I'm confused why this compiles in Scala 3.4.2...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label
Projects
None yet
Development

No branches or pull requests

1 participant