Skip to content

Regression in augustnagro/magnum for implicit search #20342

Closed
@WojciechMazur

Description

@WojciechMazur

Based on OpenCB failure found in augustnagro/magnum - build logs

Compiler version

Last good release: 3.4.2-RC1-bin-20240311-02c2a6e-NIGHTLY
First bad release: 3.4.2-RC1-bin-20240312-3694d95-NIGHTLY
Bisect points to b28d4c1

Minimized code

class Repo[EC, E](using defaults: RepoDefaults[EC, E])
trait RepoDefaults[EC, E]
object RepoDefaults:
  inline given genImmutableRepo[E: DbCodec]: RepoDefaults[E, E] = ???
  inline given genRepo[EC: DbCodec, E: DbCodec]: RepoDefaults[EC, E] = ???

trait DbCodec[E]

case class PersonCreator(name: String)
case class Person(id: Long)
given DbCodec[Person] = ???
given DbCodec[PersonCreator] = ???

@main def Test = 
  val personRepo = Repo[PersonCreator, Person]

Output

[error] ./sandbox.scala:15:47
[error] No best given instance of type RepoDefaults[PersonCreator, Person] was found for parameter defaults of constructor Repo in class Repo.
[error] I found:
[error] 
[error]     RepoDefaults.genImmutableRepo[E](
[error]       /* ambiguous: both given instance given_DbCodec_Person and given instance given_DbCodec_PersonCreator match type DbCodec[E] */
[error]         summon[DbCodec[E]]
[error]     )
[error] 
[error] But both given instance given_DbCodec_Person and given instance given_DbCodec_PersonCreator match type DbCodec[E].
[error]   val personRepo = Repo[PersonCreator, Person]
[error]                                               ^
Error compiling project (Scala 3.5.0-RC1-bin-20240502-05354ba-NIGHTLY, JVM (17))

Expectation

Should compile

Metadata

Metadata

Labels

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

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions