Behaviour of implicit search #22171
Unanswered
NPCRUS
asked this question in
General Question
Replies: 1 comment 6 replies
-
summon[Show2[B.type]] is ambiguous, which becomes evident when compiling val t1: Show2[B.type] = Show2.given_Show2_T[B.type]
val t2: Show2[B.type] = Show2.given_Show2_T[A] |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello folks, I was researching different cases of variance quirks in scala and I bumped into this one for which I so far wasn't able to produce any sensible explanation whatsoever, maybe somebody could help me here with explanation or perhaps it's a bug...
Here we have invariant
Show[T]
typeclass, which has been implicitly converted into contrvariantShow2[-T]
typeclass. This variance difference causing an ambiguous implicit search error.Interestingly this example(when givens are replaced with implicits) is compiling in scala2, therefore I thought that there are some changes in implicit resolution, but going through this multiple times didn't really help.
Another note is that results is the same for all stable major versions of scala3, I tested with: 3.3.3, 3.4.2, 3.5.2, 3.6.2-RC1
Since original
Show[T]
is invariant, I expect search to be able to narrow it down to one of the presented givensand I get this error:
Beta Was this translation helpful? Give feedback.
All reactions