-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Value types are not properly compared in TypeComparer
#2430
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
After this issue is resolved, the work from #2415 makes erasure |
|
I agree with @smarter. This is intentional, and done so that erasure is forced to insert the proper casts. |
I talked with @felixmulder and we did find one issue: when a value class underlying type is also a value class, you may need to wrap/unwrap using |
During Erasure, A value class A with underlying type U has its type semi-erased to ErasedValueType(A, [semi-erasure of U]). To make Erasure typecheck, special cast functions A.evt2u$ and A.u2evt$ are used to cast between the underlying type and the class EVT type. Before this commit, this conversion was not always correctly done for nested value classes, this did not lead to problem in practice but broke -Ycheck:erasure.
During Erasure, a value class A with underlying type U has its type semi-erased to ErasedValueType(A, [semi-erasure of U]). To make Erasure typecheck, special cast functions A.evt2u$ and A.u2evt$ are used to cast between the underlying type and the class EVT type. Before this commit, this conversion was not always correctly done for nested value classes, this did not lead to problem in practice but broke -Ycheck:erasure.
Fix #2430: Make Erasure pass Ycheck
The following subtyping test fails
Ycheck
after erasure:In tree checker:
This is what causes erasure not to be
Ycheck
able. The next phase,ElimErasedValueType
, removes theErasedValueType
s and casts so that it is again,Ycheck
able.ping @odersky
The text was updated successfully, but these errors were encountered: