Suppose i want to overload a function that gives trouble because of type erasure:
object test : def f(list: List[Int]) = list.sum.toString def f(list: List[String]) = list.mkString(",")
object test : def f(list: List[Int]) = list.sum.toString @targetName("HocusPocus") def f(list: List[String]) = list.mkString(",")
And yes, it is also well documented.
But what i fail to see is, if the given name in
@targetName is never used, and is just there to fix and mask this limitation in function overloading, why can this not be done directly by the compiler? Giving a name that is never used just does not feel ‘Scala’ where at times a lot of machinery is in place to remove unused names and the related boilerplate.