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
scala>importannotation.targetName||objectFoo {
|defapply[A<:Int]:Int=0|@targetName("applyS") defapply[B<:String]:String="0"| }
||Foo[Int]
8|Foo[Int]
|^^^
|Ambiguous overload. The overloaded alternatives of method apply in objectFoowith types
| [B<:String] =>String| [A<:Int] =>Int|both matchtypearguments [Int] and expected type<?>
Expectation
I would expect that to work.
Recently we merged a PR in Scala 2 that fixed it for HKTs: scala/scala#9405
Note that this worked in Scala 2 way before my PR (which is just the natural extension to HKTs):
I agree it should work. The problem is that bounds-checking is not part of applicability (it is checked later to avoid cycles), so overloading resolution ignores it.
When resolving overloaded polymorphic variants with explicit type
arguments, discard those variants where the given argument does not
fit the type parameter bounds.
Fixesscala#11015
Reporting this as a bug because I would argue it's about Scala 2 compatibility.
Minimized code
Output
Expectation
I would expect that to work.
Recently we merged a PR in Scala 2 that fixed it for HKTs: scala/scala#9405
Note that this worked in Scala 2 way before my PR (which is just the natural extension to HKTs):
If this change is intentional maybe it should be documented in overload-resolution.md
The text was updated successfully, but these errors were encountered: