-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Method call fails for overloaded methods with default parameters #12679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The same example without higher kinded type works well: object Foo extends App {
def foo(qux: String, quux: String = ""): Unit = ()
def foo(qux: Boolean): Unit = ()
def example(maybeQux: Option[String], bool: Boolean) =
maybeQux.fold(foo(bool))(foo(_))
} |
I have updated your example to remove the dependency on cats - it still fails with the same error |
It's also reproduce on |
I tried some things, but have to give up fow now. The combination of overloading and default parameters is so complex that any change is extremely difficult. I think the right move is to go back to the drawing board and change the design of default parameters. Instead of the super-fragile default getter name encoding we should attach an inline expression directly to the parameter. That would improve and expressiveness, performance and decrease complexity. But it's an incompatible language change since default arguments could not be overridden anymore. So, unless someone else feels more courageous than myself, don't hold your breath for a fix. It's better to avoid the combination of overloading and default parameters, except if the default parameter appears in the first parameter clause of the method. |
[skip community_build] closes scala#12679
[skip community_build] closes scala#12679
Uh oh!
There was an error while loading. Please reload this page.
Compiler version
3.0.0
Minimized code
https://scastie.scala-lang.org/LnY1kBvlQs2zclBzaeA0Vg
Output
Expectation
That works in Scala 2 (both 2.12.13 and 2.13.6).
The text was updated successfully, but these errors were encountered: