-
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
No longer able to extract a type from an intersection #19999
Comments
You want |
Minimization: class InIntersection[I, A]
def derived[A, R0]: InIntersection[A & R0, A] = new InIntersection[A & R0, A]
val x: InIntersection[Int & String, Int] = derived // error Here is the error with -explain
Interestingly it compiles OK if the second type parameter is dropped: class InIntersection[I]
def derived[A, R0]: InIntersection[A & R0] = new InIntersection[A & R0]
var x: InIntersection[Int & String] = derived // OK |
Hint to issue reporters: If possible avoid reference to summon, implicitly, =:=, or <:<, or other implicit mechanisms. It just increases the footprint where the error could be. Of course, if the error is linked to implicits and cannot be reproduced without them, do report it like that. |
The example also compiles if the order of parameters is reversed: class InIntersection[A, I]
def derived[A, R0]: InIntersection[A, A & R0] = new InIntersection[A, A & R0]
var x: InIntersection[Int, Int & String] = derived What happens in the failing example is that the first constraint |
We could maybe try to re-order the comparison of type arguments, delaying constraints that look hard. A hard constraint would be one that has a & on the LHS or an | on the RHS, since both of these need a fork via either. |
When comparing arguments of two applied types, perform hard comparisons after easy ones. A comparison if hard if it entails a subtype test A <: B where A is an AndType or B is an OrType. Such comparisons need to perform an either, which might lose solutions. Fixes scala#19999
When comparing arguments of two applied types, perform hard comparisons after easy ones. A comparison is hard if it entails a subtype test A <: B where A is an AndType or B is an OrType. Such comparisons need to perform an either, which might lose solutions. Fixes #19999
When comparing arguments of two applied types, perform hard comparisons after easy ones. A comparison if hard if it entails a subtype test A <: B where A is an AndType or B is an OrType. Such comparisons need to perform an either, which might lose solutions. Fixes #19999 [Cherry-picked bda6763][modified]
Compiler version
Does not compile on 3.4.0 (or 3.0.0, 3.1.0, 3.2.0, 3.3.0)
Does compile in 2.13.12
Minimized code
Output
Expectation
I would expect it to compile. It does compile with scala 2.13.12 (if I change the
&
towith
).The text was updated successfully, but these errors were encountered: