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
packageexampletraitShow[O]:def (o: O).show:StringclassBox[A]
classFoogivenShow[Foo] = _.toString
given [A](usingShow[A]):Show[Box[A]] = _.toString
defrun(s: Box[Box[Foo]]):Unit=
summon[Show[Box[Box[Foo]]]].show(s) // it can find the given here
println(s"step: ${s.show}") // tries to call show on Show[Box[Foo]]
Compilation output
-- [E008] MemberNotFoundError: givens.scala:14:2214| println(s"step: ${s.show}")
|^^^^^^| value show is not a member of example.Box[example.Box[example.Foo]].
|An extension method was tried, but could not be fully constructed:
|| example.givens$package.given_Show_Box[example.Foo](
| example.givens$package.given_Show_Foo
| ).show(s)
The text was updated successfully, but these errors were encountered:
The problem is that we are asking to find an implicit given information that is far apart. Indeed we need to construct the full implicit so that afterwards we can run show on it, and have it applied be to the right argument. Currently the argument's type is not propagated. This is probably a prudent thing to do since forcing argument types like that can cause problems by itself. For instance, one could fail to compute a parameter type, or miss another implicit conversion.
I fear we have reached the limit of what bidirectional type inference can do here. I see no way to improve this that might not potentially break other things.
Minimized code
Compilation output
The text was updated successfully, but these errors were encountered: