Skip to content

Regression in Scala 3.5.0-RC1 related to implicit search and match types that return type lambdas #20482

Closed
@mrdziuban

Description

@mrdziuban

Compiler version

3.5.0-RC1, the issue is not present in 3.4.2

Minimized code

https://scastie.scala-lang.org/mrdziuban/lnO61Y1VSSy2xu5NuyAg8w

trait WrapperType[A]

case class Foo[A]()

case class Bar[A]()

type FooToBar[D[_]] = [A] =>> D[Unit] match {
  case Foo[Unit] => Bar[A]
}

case class Test()
object Test {
  implicit val wrapperType: WrapperType[Bar[Test]] = new WrapperType[Bar[Test]] {}
}

val test = summon[WrapperType[FooToBar[Foo][Test]]]

Output

16 |val test = summon[WrapperType[FooToBar[Foo][Test]]]
   |                                                   ^
   |No given instance of type WrapperType[FooToBar[Foo][Test]] was found for parameter x of method summon in object Predef
   |
   |The following import might fix the problem:
   |
   |  import Test.wrapperType
   |

Expectation

Test.wrapperType should satisfy the implicit search of the summon call.

Interestingly, if I change FooToBar to not return a type lambda, then everything compiles correctly, i.e.

type FooToBar[D[_], A] = D[Unit] match {
  case Foo[Unit] => Bar[A]
}
// ...
val test = summon[WrapperType[FooToBar[Foo, Test]]]

Metadata

Metadata

Labels

area:implicitsrelated to implicitsitype:bugregressionThis worked in a previous version but doesn't anymore

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions