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
% scalac -3.1.2-Xprint:typer Main.scala
--Error:Main.scala:4:6-------------------------------------------------------4|deffoo(x:String="") =???|^| two or more overloaded variants of method foo have default arguments
[[syntax trees at end of typer]] // Main.scalapackage<empty> {
finallazy module valMain$package:Main$package=newMain$package()
final module classMain$package() extendsObject() {
this:Main$package.type=>extension (i: Int) deffoo(x: String):Nothing=???deffoo$default$2(i: Int):String=""extension (d: Double) deffoo(x: String):Nothing=???deffoo$default$2(d: Double):String=""
}
}
1 error found
Expectation
This should compile, as the methods aren't on the same type, so they should not be ambiguous. Similar to #12245, also @targetName has no effect on the error
The text was updated successfully, but these errors were encountered:
The best solution for this is to wait until we improve how we handle default arguments. We plan to inline them, which would imply we would not need the foo$default$2 at runtime. We still have some hurdles to overcome to get there.
So basically, this limitation isn't a bug and comes from the compiler design and its representation of extension methods and default arguments. The @targetName annotation doesn't affect a typechecker where the error is thrown.
Compiler version
3.1.2
Minimized code
Output
Expectation
This should compile, as the methods aren't on the same type, so they should not be ambiguous. Similar to #12245, also
@targetName
has no effect on the errorThe text was updated successfully, but these errors were encountered: