You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#16664 attempts to fix possible unsoundness issues, but I think it is too limiting.
Consider the following code that relies on singleton type from the parent class parameter.
The error that is reported is definitely correct, given the inferred type. If you explicitly write the type that gets inferred, i.e., Container[Tuple1[argC.type]], it would (should) rightfully complain. The type you wrote explicitly was Container[Tuple1[C]], which does not refer to argC and is therefore fine.
Now the type that does get inferred is clearly not the best one in this specific example. If type inference inferred Container[Tuple1[C]] instead of Container[Tuple1[argC.type]], the original example would compile. The inference is caught between a rock and a hard place: it is instructed to select a singleton type because of the Singleton bound, but it the singleton type it infers is not valid in this context.
#16664 attempts to fix possible unsoundness issues, but I think it is too limiting.
Consider the following code that relies on singleton type from the parent class parameter.
Compiler version
3.3.1-RC1-bin-20230301-0df5ae2-NIGHTLY
Minimized code
If we explicitly apply the type argument, this compiles fine:
Output
Expectation
No error.
Note: Scala 2 also fails in the same situation (with a different error), but I don't see the how unsoundness is formed with singletons.
The text was updated successfully, but these errors were encountered: