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
I decided to report yet another example of #5592 because it seemed to me that Scalac is much closer to figuring out the right thing. It seems that type inference suddenly becomes stupid when an implicit conversion is applied implicitly rather than explicitly. In all other instances of #5592, instead, either type inference doesn't work even if the implicit conversion is applied explicitly, or it is clear that adding the conversion clearly gives more information to type inference (i.e. the only unifier between type variables A and B requires an implicit conversion).
The last expression does not typecheck, yet it is obtained from asExp(tuple2ToTuple2ExpPrime( ((a, b), c) )) by removing an unambiguous implicit conversion - the compiler can also consider pure, but tuple2ToTuple2ExpPrime is strictly more specific.
Actually typing the last expression gives:
scala> asExp(((a, b), c)) //does not compile
<console>:19:error: Noimplicit view available from (Exp[Int], Exp[java.lang.String]) =>Exp[ArgFOO1].
asExp(((a, b), c)) //does not compile^
ArgFOO1 appears in the output, hence the compiler did figure out that tuple2ToTuple2ExpPrime was to be applied.
Notice that I want the compiler to use tuple2ToTuple2ExpPrime twice here, but even if I change the example to avoid that, I experience the same issue.
In the same console, let's paste this further code:
scala> asExp(((a, b, c), d)) //does not compile
<console>:23:error: Noimplicit view available from (Exp[Int], Exp[java.lang.String], Exp[Int]) =>Exp[ArgFOO1].
asExp(((a, b, c), d)) //does not compile^
As a last touch, E1 <% Exp[ArgFOO1] requires in practice that E1 and Exp[ArgFOO1] to be distinct, but that's boring, as I believe it is just another example of #3346:
scala> asExp( (asExp( (a, b) ), c) )
<console>:19:error: Noimplicit view available from Exp[Int] =>Exp[ArgFOO1].
asExp( (asExp( (a, b) ), c) )
^
scala>implicitdefidentity2[A](x: A):A= x
identity2: [A](x: A)A
scala> asExp( (asExp( (a, b) ), c) )
<console>:21:error: Noimplicit view available from Exp[Int] =>Exp[ArgFOO1].
asExp( (asExp( (a, b) ), c) )
Actually, this suggests that this is a dup of #3346; but I did not know that applying the conversion explicitly could help. I hope this is helpful.
The text was updated successfully, but these errors were encountered:
I decided to report yet another example of #5592 because it seemed to me that Scalac is much closer to figuring out the right thing. It seems that type inference suddenly becomes stupid when an implicit conversion is applied implicitly rather than explicitly. In all other instances of #5592, instead, either type inference doesn't work even if the implicit conversion is applied explicitly, or it is clear that adding the conversion clearly gives more information to type inference (i.e. the only unifier between type variables A and B requires an implicit conversion).
The last expression does not typecheck, yet it is obtained from
asExp(tuple2ToTuple2ExpPrime( ((a, b), c) ))
by removing an unambiguous implicit conversion - the compiler can also considerpure
, buttuple2ToTuple2ExpPrime
is strictly more specific.Actually typing the last expression gives:
ArgFOO1
appears in the output, hence the compiler did figure out thattuple2ToTuple2ExpPrime
was to be applied.Notice that I want the compiler to use
tuple2ToTuple2ExpPrime
twice here, but even if I change the example to avoid that, I experience the same issue.In the same console, let's paste this further code:
Error:
As a last touch,
E1 <% Exp[ArgFOO1]
requires in practice thatE1
andExp[ArgFOO1]
to be distinct, but that's boring, as I believe it is just another example of #3346:Actually, this suggests that this is a dup of #3346; but I did not know that applying the conversion explicitly could help. I hope this is helpful.
The text was updated successfully, but these errors were encountered: