-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
area:reportingError reporting including formatting, implicit suggestions, etcError reporting including formatting, implicit suggestions, etcbetter-errorsIssues concerned with improving confusing/unhelpful diagnostic messagesIssues concerned with improving confusing/unhelpful diagnostic messagesitype:enhancement
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 along these lines (but needs to be simpler):
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.
Metadata
Metadata
Assignees
Labels
area:reportingError reporting including formatting, implicit suggestions, etcError reporting including formatting, implicit suggestions, etcbetter-errorsIssues concerned with improving confusing/unhelpful diagnostic messagesIssues concerned with improving confusing/unhelpful diagnostic messagesitype:enhancement