-
Notifications
You must be signed in to change notification settings - Fork 1.1k
export
interacting weirdly with scala.Conversion
#12700
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
Comments
So far, I have not seen any failures of this kind pertaining to other |
In the same compilation unit, the error is
It works anywhere when importing from Is #12591 a similar question, to reconcile two paths through an export, either for behavior or just for messaging? |
I believe #12591 is getting at the same idea: In my repro above, the |
@erikerlandson it works if you
|
I also imported that in my testing. However, I will play with it some more and see if I can find something else wrong in my code |
Out of curiosity, have you tested in a REPL? generally these things work either way but occasionally a repl causes subtle differences |
I was going to say maybe REPL is not doing your import. I didn't try in REPL, just run class from CLI. |
Oh right, |
yes, I've been running with |
Aha. For the record
|
weird - well I'll have to double check my local reproducer then |
so... my reproducer above also works for me, I might have missed the However, I did figure out what was different about given g1[U1, U2](using conv: Coefficient[U1, U2]):
scala.Conversion[Quantity[Double, U1], Quantity[Double, U2]] =
new scala.Conversion[Quantity[Double, U1], Quantity[Double, U2]]:
val c = conv.coef.toDouble
def apply(q: Quantity[Double, U1]): Quantity[Double, U2] =
(q.value * c).withUnit[U2] And what's happening is that |
actual error looks like this: scala> summon[scala.Conversion[Quantity[Double, Yard], Quantity[Double, Meter]]]
1 |summon[scala.Conversion[Quantity[Double, Yard], Quantity[Double, Meter]]]
| ^
|units are not convertable: (TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),Any)) (TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),Nothing)) almost like scala is forcing the types to |
The old joke for Scala 2 was to switch variances until the code compiles. I think for Scala 3, it's add |
Yes, that other issue looks very similar. Hilarious, it was the definition for transparent inline given [U1, U2]: Coefficient[U1, U2] =
${ coulomb.infra.meta.coefficient[U1, U2] } |
Works now: scala> val t: Quantity[Double, Meter] = (1D.withUnit[Yard])
val t: coulomb.Quantity[Double, coulomb.si.Meter] = 0.9144 |
Compiler version
3.0.0
Minimized code
Output
Expectation
I would expect scala to understand that
repro.wrap.Wrap
andrepro.Wrap
are the same thing, and not error out.The text was updated successfully, but these errors were encountered: