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
The above example works but if I try to summon[Test[Int, Test[String, Int]]], this produces an ambiguous implicit argument at using A.
I did some tests and noticed these behaviours:
Works when removing the inline modifiers (skipped because Test[Int, Test[String, Int]] doesn't match Test[A, Test[A, B]])
Works if there's no using A (skipped because Test[Int, Test[String, Int]] doesn't match Test[A, Test[A, B]])
Works if A and B are covariant in Test
Doesn't work if A and B are invariant or contravariant
From what I tested, the compiler seems to try to get the using A parameter where A = ? before checking the returned type.
Expectation
I would expect the compiler to just ignore inline given [A, B](using A): Test[A, Test[A, B]] = new Test when summoning Test[Int, Test[String, Int]] and search for another given instance (or raise a "no implicit found" error if there's no matching instance).
I actually see 2 potential solutions:
Make the compiler verify the returned type when he tries to infer the generic types before looking for the using parameter(s)
If a given instance produces an ambiguity error, check for another matching given instance before raising it.
Note: this is possibly related to #7586 and #14169
The text was updated successfully, but these errors were encountered:
Compiler version
3.1.0
Minimized code
Output
The above example works but if I try to
summon[Test[Int, Test[String, Int]]]
, this produces an ambiguous implicit argument atusing A
.I did some tests and noticed these behaviours:
inline
modifiers (skipped becauseTest[Int, Test[String, Int]]
doesn't matchTest[A, Test[A, B]]
)using A
(skipped becauseTest[Int, Test[String, Int]]
doesn't matchTest[A, Test[A, B]]
)A
andB
are covariant inTest
A
andB
are invariant or contravariantFrom what I tested, the compiler seems to try to get the
using A
parameter whereA = ?
before checking the returned type.Expectation
I would expect the compiler to just ignore
inline given [A, B](using A): Test[A, Test[A, B]] = new Test
when summoningTest[Int, Test[String, Int]]
and search for another given instance (or raise a "no implicit found" error if there's no matching instance).I actually see 2 potential solutions:
using
parameter(s)Note: this is possibly related to #7586 and #14169
The text was updated successfully, but these errors were encountered: