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
defround(f: Float, digits: Int=0):Float=???//@scala.annotation.targetName("roundDouble") // does not change anythingdefround(d: Double, digits: Int=0):Double=???
Output
$ scalac Main.scala -Xprint:typer
--Error:Main.scala:4:6------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------4|defround(d: Double, digits: Int=0):Double=???|^| two or more overloaded variants of method round have default arguments
-- [E120] NamingError:Main.scala:4:37---------------------------------------------------------------------------------------------------------------------------------------------------------------------------4|defround(d: Double, digits: Int=0):Double=???|^|Doubledefinition:
|defround$default$2:=>Int in packageobjectMain$package at line 2 and
|defround$default$2:=>Int in packageobjectMain$package at line 4| have the same typeafter erasure.
||Consider adding a @targetName annotation to one of the conflicting definitions
|for disambiguation.
2 errors found
Expectation
The code should compile.
If that is not possible because the names clash (as the first error suggests), it should compile with the @targetName given.
In no case should the compiler propose to annotate methods it generated itself. (def round$default$2)
Comments
If I add @targetName to one of the round methods, the output stays exactly the same.
result of Main.scala after typer:
package<empty> {
finallazy module valMain$package:Main$package$ =newMain$package$()
final module classMain$package$() extendsObject() { this:Main$package.type=>defround(f: Float, digits: Int):Float=???defround$default$2:Int=0@scala.annotation.targetName("roundDouble") defround(d: Double, digits: Int):Double=???defround$default$2:Int=0
}
}
Maybe the problem could be solved if the generated method names would use the given target name?
The text was updated successfully, but these errors were encountered:
Compiler version
3.0.0-RC3
Minimized code
Output
Expectation
The code should compile.
If that is not possible because the names clash (as the first error suggests), it should compile with the
@targetName
given.In no case should the compiler propose to annotate methods it generated itself. (
def round$default$2
)Comments
If I add
@targetName
to one of theround
methods, the output stays exactly the same.Maybe the problem could be solved if the generated method names would use the given target name?
The text was updated successfully, but these errors were encountered: