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 augustnagro/magnum for implicit search #20342

Closed
WojciechMazur opened this issue May 6, 2024 · 3 comments · Fixed by #20371
Closed

Regression in augustnagro/magnum for implicit search #20342

WojciechMazur opened this issue May 6, 2024 · 3 comments · Fixed by #20371
Assignees
Labels
area:implicits related to implicits itype:bug regression This worked in a previous version but doesn't anymore
Milestone

Comments

@WojciechMazur
Copy link
Contributor

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

@WojciechMazur WojciechMazur added itype:bug area:implicits related to implicits regression This worked in a previous version but doesn't anymore labels May 6, 2024
@mbovel mbovel self-assigned this May 7, 2024
@odersky
Copy link
Contributor

odersky commented May 9, 2024

So we have this regression when #19922 is enabled and some other regressions that #19922 fixed. There is no way to address both sets of regressions at the same time, since each depend on a particular detail of the inference being enabled or disabled, respectively.

So what do we do? Some possible criteria to decide:

So overall I think reverting #19922 is the right thing to do.

@odersky odersky assigned odersky and unassigned mbovel May 9, 2024
@odersky
Copy link
Contributor

odersky commented May 9, 2024

In fact I am not sure what LTS does?

@odersky
Copy link
Contributor

odersky commented May 9, 2024

One other argument for reverting #19922: Without #19922, if type inference breaks we can heal this by making the inline method in question transparent. With #19922, if type inference breaks the other way, there is no easy solution.

odersky added a commit to dotty-staging/dotty that referenced this issue May 9, 2024
Reverts parts of scala#19922.

Fixes scala#20342

The logic that we should ignore declared result types of inline methods really only applies
to transparent inlines.
odersky added a commit to dotty-staging/dotty that referenced this issue May 9, 2024
Reverts parts of scala#19922.

Fixes scala#20342, scala#20297

The logic that we should ignore declared result types of inline methods really only applies
to transparent inlines.
noti0na1 pushed a commit to dotty-staging/dotty that referenced this issue May 14, 2024
Reverts parts of scala#19922.

Fixes scala#20342, scala#20297

The logic that we should ignore declared result types of inline methods really only applies
to transparent inlines.
noti0na1 added a commit to dotty-staging/dotty that referenced this issue May 14, 2024
odersky added a commit to dotty-staging/dotty that referenced this issue Jun 11, 2024
Reverts parts of scala#19922.

Fixes scala#20342, scala#20297

The logic that we should ignore declared result types of inline methods really only applies
to transparent inlines.
odersky added a commit to dotty-staging/dotty that referenced this issue Jun 11, 2024
Reverts parts of scala#19922.

Fixes scala#20342, scala#20297

The logic that we should ignore declared result types of inline methods really only applies
to transparent inlines.
odersky pushed a commit to dotty-staging/dotty that referenced this issue Jun 11, 2024
odersky added a commit that referenced this issue Jun 12, 2024
Reverts parts of #19922.

Fixes #20342 
Fixes #20297

The logic that we should ignore declared result types of inline methods
really only applies to transparent inlines.
@Kordyjan Kordyjan added this to the 3.5.1 milestone Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:implicits related to implicits itype:bug regression This worked in a previous version but doesn't anymore
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants