-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Reinstantiate restriction to transparent inline methods #20371
Conversation
It seems this breaks more in the CB. Not sure what to do, I think I'll give this up for now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a test for #20342, and it passes locally as well.
So, LGTM now.
@WojciechMazur So, this test fixes two regressions and probably opens two others that were fixed by #19922. Nevertheless, from a point of the program logic this is the right thing to do. Should we merge this (which would revert to the 3.4 and LTS behavior) or test the open CB before that? |
I've run the OpenCB, it does in fact reintroduce the 2 regressions mentioned above. Seems to also introduce a new regression in
I can't really tell should it be merged or not, as it seems like in each some projects would fail to compile. |
Reproduction for final class StrictEqual[V]
final class Less[V]
type LessEqual[V] = Less[V] | StrictEqual[V]
object TapirCodecIron:
trait ValidatorForPredicate[Value, Predicate]
trait PrimitiveValidatorForPredicate[Value, Predicate]
extends ValidatorForPredicate[Value, Predicate]
given validatorForLessEqual[N: Numeric, NM <: N](using
ValueOf[NM]
): PrimitiveValidatorForPredicate[N, LessEqual[NM]] = ???
given validatorForDescribedOr[N, P](using
IsDescription[P]
): ValidatorForPredicate[N, P] = ???
trait IsDescription[A]
object IsDescription:
given derived[A]: IsDescription[A] = ???
@main def Test = {
import TapirCodecIron.{*, given}
type IntConstraint = LessEqual[3]
summon[ValidatorForPredicate[Int, IntConstraint]]
} Without -- Warning: /Users/wmazur/projects/sandbox/tapir.repro.scala:24:51 -------------
24 | summon[ValidatorForPredicate[Int, IntConstraint]]
| ^
|Given search preference for TapirCodecIron.ValidatorForPredicate[Int, IntConstraint] between alternatives (TapirCodecIron.validatorForDescribedOr :
| [N, P]
| (using x$1: TapirCodecIron.IsDescription[P]):
| TapirCodecIron.ValidatorForPredicate[N, P]
|) and (TapirCodecIron.validatorForLessEqual :
| [N, NM <: N]
| (implicit evidence$1: Numeric[N], x$1: ValueOf[NM]):
| TapirCodecIron.PrimitiveValidatorForPredicate[N, LessEqual[NM]]
|) will change
|Current choice : the second alternative
|New choice from Scala 3.6: none - it's ambiguous
1 warning found Under 3.5-migration it fails with compilation errror: -- [E172] Type Error: /Users/wmazur/projects/sandbox/tapir.repro.scala:24:51 ---
24 | summon[ValidatorForPredicate[Int, IntConstraint]]
| ^
|Ambiguous given instances: both given instance validatorForDescribedOr in object TapirCodecIron and given instance validatorForLessEqual in object TapirCodecIron match type TapirCodecIron.ValidatorForPredicate[Int, IntConstraint] of parameter x of method summon in object Predef Seems like the 3.5-migration flag is treated as the 3.6 |
If the broken projects need only add a |
@SethTisue One of the failing tests (#19415) could be fixed in its minimization by refining the inference scheme. The other is new code (#19479), using inline givens and could trivially be changed by adding a |
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.
- Take MatchTypes into account - Add test cases for tests that failed originally and would otherwise fail again after this PR. i19415.scala is fixed by the MatchType extension. i19749.scala was fixed by adding a `transparent`.
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.