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
Nogiveninstance of type (1:Int) | ("2":String) | ('3':Char) | (4:Int) |Nothing=:= ((1:Int) |
(("2":String) | (('3':Char) | ((4:Int) |Nothing)))) was found for parameter x of method summon in objectPredef
Expectation
I expect any combination and order of the types in a union of the same individual types to be equivalent. Came across this when working on an HList using inline and used the Fold/Union match types as defined for the tuples.
The failing case would be translated to following summon:
valfails: <error no implicit values were found that match type (1 : Int) | ("2" : String) =:= L> =
summon[1.type|=:=["2".type, L]](/* missing */summon[(1:Int) | ("2":String) =:=L])
As you can see the summon[1 | "2" =:= L] is interpreted as summon[1.type | =:=["2".type, L]] which is equivalent of summon[1.type | ("2".type =:= L)]]
That because =:= is not a special construct but a class constructed at compile time
@implicitNotFound(msg = "Cannot prove that ${From} =:= ${To}.")
sealed abstract class =:=[From, To] extends (From <:< To)
The code was interpreted that way since 3.0.0 so probably it is not a bug
There are no plans to change to how the types would be resolved, eg. to allow skip using parenthesis on the left/right hand side of =:=. Using type aliases or wrapping complex union/intersection types in parenthesis is recommended to mitigate this issue.
Compiler version
Versions 3.2.0 and 3.2.1-RC2
Minimized code
See examples
Output
Expectation
I expect any combination and order of the types in a union of the same individual types to be equivalent. Came across this when working on an HList using inline and used the Fold/Union match types as defined for the tuples.
May be related to:
The text was updated successfully, but these errors were encountered: