-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Subtyping info lost when pattern matching on type of expression #15735
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
@prolativ I'm just looking at the code of iskra, trying to implement the |
No, this should not be a blocker. I believe this problem could be worked around by replacing case '[Bar[`num`]] => with case '[Bar[n]] if Type.of[n] == Type.of[num] => |
You probably need something like Type.of[n] =:= Type.of[num] |
Solution- case '{ $enc: Foo { type Number = num } } =>
+ case '{ type num <: Int; $enc: Foo { type Number = `num` } } => |
@nicolasstucki was there any code changed in the compiler to fix this (there's no PR linked here)? Or is your SIP supposed to actually solve the problem? |
It is not a feature that is intended to work. In general, we have many issues related to type variable bound inference. We know that we should not be inferring those bounds because this kind of inference goes beyond what Scala is supposed to be able to do. A second issue is that this inference can infer useless bounds such as I am still working on a migration path out of this issue. I will open a SIP once I have all the pieces figured out. This ability to infer type variable bounds was added as a workaround to be able have type matches with the variables that are bounded. Now we solved the original limitation with SIP-53. This SIP was the first step toward fixing this problem. |
Compiler version
3.2.1-RC1-bin-20220721-634c580-NIGHTLY and earlier
Minimized code
Output
Expectation
The compiler should be aware that
num
has to be a subtype ofInt
and the compilation should succeedThe text was updated successfully, but these errors were encountered: