Open
Description
Compiler version
3.7.0
Minimized example
import scala.scalajs.js
abstract class A:
type Props
def apply(p: Props) = ()
type UndefOr2[A] = A | Unit
object D extends A:
case class Props()
def apply(a: UndefOr2[String]) = ()
Output Error/Warning message
Name clash between defined and inherited member:
def apply(p: A.this.Props): Unit in class A at line 7 and
def apply(a: Playground.UndefOr2[String]): Unit in object D at line 27
have the same type after erasure.
Consider adding a @targetName annotation to one of the conflicting definitions
for disambiguation
Why this Error/Warning was not helpful
It doesn't tell me what the "same type" actually is.
Suggested improvement
Ideally it would be something like this:
We need to have the class be the "least specific" type it can be in the bytecode.
For A: there's an invisible >: Nothing <: Any, meaning the least specific type is Any for which the class is Object.
For D: the type is SomeCaseClass | Unit, for which the shared class is Object
As both A and D are of type Object they are in conflict.
Consider adding a @TargetNAME annotation to either A or D.