Skip to content

Commit 857ed96

Browse files
committed
Print double definitions signatures at Typer
Fixes #14966
1 parent 53f5531 commit 857ed96

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2174,10 +2174,12 @@ import transform.SymUtils._
21742174
else
21752175
"Name clash between inherited members"
21762176

2177-
em"""$clashDescription:
2178-
|${previousDecl.showDcl} ${symLocation(previousDecl)} and
2179-
|${decl.showDcl} ${symLocation(decl)}
2180-
|""" + details
2177+
atPhase(typerPhase) {
2178+
em"""$clashDescription:
2179+
|${previousDecl.showDcl} ${symLocation(previousDecl)} and
2180+
|${decl.showDcl} ${symLocation(decl)}
2181+
|"""
2182+
} + details
21812183
}
21822184
def explain = ""
21832185
}

tests/neg/i14966.check

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- [E120] Naming Error: tests/neg/i14966.scala:2:11 --------------------------------------------------------------------
2+
2 | export s.* // error
3+
| ^
4+
| Double definition:
5+
| final def concat[B >: T](suffix: IterableOnce[B]): Set[B] in class B at line 2 and
6+
| final def concat(that: IterableOnce[T]): Set[T] in class B at line 2
7+
| have the same type after erasure.
8+
|
9+
| Consider adding a @targetName annotation to one of the conflicting definitions
10+
| for disambiguation.

tests/neg/i14966.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class B[T](val s: Set[T]):
2+
export s.* // error

0 commit comments

Comments
 (0)