Skip to content

Commit 9deb808

Browse files
committed
Refine @TargetNAME hinting
Don't issue the hint of one of the conflicting definitions already carries a @TargetNAME.
1 parent ce53d89 commit 9deb808

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

compiler/src/dotty/tools/dotc/reporting/messages.scala

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2079,10 +2079,16 @@ import transform.SymUtils._
20792079
case MethodNotAMethodMatch =>
20802080
"neither has parameters."
20812081
case FullMatch =>
2082-
i"""have the same$nameAnd type after erasure.
2083-
|
2084-
|Consider adding a @targetName annotation to one of the conflicting definitions
2085-
|for disambiguation."""
2082+
val hint =
2083+
if !decl.hasAnnotation(defn.TargetNameAnnot)
2084+
&& !previousDecl.hasAnnotation(defn.TargetNameAnnot)
2085+
then
2086+
i"""
2087+
|
2088+
|Consider adding a @targetName annotation to one of the conflicting definitions
2089+
|for disambiguation."""
2090+
else ""
2091+
i"have the same$nameAnd type after erasure.$hint"
20862092
}
20872093
}
20882094
else ""

tests/neg/override-erasure-clash.check

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,3 @@
55
| def f(): Int in class A at line 3 and
66
| def g(): Int in class B at line 5
77
| have the same name and type after erasure.
8-
|
9-
| Consider adding a @targetName annotation to one of the conflicting definitions
10-
| for disambiguation.

0 commit comments

Comments
 (0)