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
This was a very hard puzzler. First, Scala 2 and Scala 3 behave the same (different error messages but same outcome).
Second, the example is quite minimal -- you change the slightest detail and it works. So let's look at it in details:
The first definition
def apply[M](m: M): Unit =
???
means that the argument cannot be pre-typed using preTypeArgs since not all expected types are functions.
If the first definition is missing, it compiles OK.
The argument _ => new Foo must have an undeclared parameter type. If you write (_: Unit) => new Foo instead, it compiles OK.
Since the argument has an undeclared parameter and it cannot be pre-typed from the outside, we assume the wildcard type <?> => <?>. That type matches both the second and the third versions of apply.
The third version of apply is more specific than the second, since it constrains its type parameter more. So that version is chosen.
The argument is now typed with expected type Unit => M where M <: Tuple, and that fails.
I think this is all as expected. Surprising? Sure. But the example is pushing it.
Compiler version
3.3.0-RC1-bin-20230119-13b8d7d-NIGHTLY
Minimized code
Output
Expectation
The overload should resolve.
The text was updated successfully, but these errors were encountered: