-
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
Unsound reduction of match types #19746
Comments
Interestingly, this kind of issue is already detected when using an intermediate type parameter for extension (self: Any) def as[T]: T =
def asX[W1 <: W[Any]](w: W1): w.X /* <- does not reduce to Any */ = self
asX(new W[T] {}) /* <- reduces to T */ In this case, we rightfully find that the scrutinee is not specific enough to determine an instance for the capture in Also note that the |
@Gedochao Probably a candidate P0, as unsoundness issues are pretty bad. |
Term refs that reference term parameters can be substituted later by more precise ones, which can lead to different instantiations of type captures. They must therefore be considered as non concrete when following `baseType`s to captures in variant positions, like we do for type param refs and other substitutable references. We actually rewrite `isConcrete` in the process to be more based on an "allow list" of things we know to be concrete, rather than an "exclusion list" of things we know to be non-concrete. That should make it more straightforward to evaluate the validity of the algorithm.
Term refs that reference term parameters can be substituted later by more precise ones, which can lead to different instantiations of type captures. They must therefore be considered as non concrete when following `baseType`s to captures in variant positions, like we do for type param refs and other substitutable references. We actually rewrite `isConcrete` in the process to be more based on an "allow list" of things we know to be concrete, rather than an "exclusion list" of things we know to be non-concrete. That should make it more straightforward to evaluate the validity of the algorithm.
Compiler version
3.4.2-RC1
Minimized example
The issue is that
w.X
reduces toAny
because the scrutineew
is widened toW[Any]
before attempting the reduction of the match type.The text was updated successfully, but these errors were encountered: