-
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
given
failing to resolve when parameter is curried prior to using
#19523
Comments
AFAIK this is treated as a feature, and not a bug, and is a difference between Scala 2 and Scala 3 type system. |
What concerns me (maybe) is that it means On the other hand, I think it will be possible to tweak the signatures of my methods to curry the |
Yes, type inference is tricky. Before implicit arguments are searched type variables appearing in preceding arguments are instantiated. If the preceding argument is 1.0 it's going to be Double, but if there are two arguments 1.0 and 1, it's going to be Double | Int. So this works as specced. |
Thank you for looking at it! In the case of methods on a class, I find this a bit unintuitive, only because once I create an I also tried this with "free" functions, and in that case the Regardless, if this isn't a bug I will proceed with figuring out how to make my signatures work with both my |
Just for posterity, doing this such that transparent inline def *[UR](using
alg: MultiplicativeSemigroup[VL]
)(qr: Quantity[VL, UR])(using
su: SimplifiedUnit[UL * UR]
): Quantity[VL, su.UO] =
alg.times(ql.value, qr.value).withUnit[su.UO] |
The mid-term goal should be to get rid of implicit conversions entirely. We should now have better way to do things. |
What is the better way? I'm happy to explore another design approach if implicit conversions are something scala would like to make obsolete. |
Compiler version
scala 3.3.1
Minimized code
Output
It seems to be incorrectly assigning type
Addable[Double | Int]
and so not finding it.Expectation
I would expect the compiler to properly type
Addable[]
regardless of whetherr
was curried before or after theusing alg
parameter.The text was updated successfully, but these errors were encountered: