Skip to content

Commit 6df4411

Browse files
oderskymichelou
authored andcommitted
Print double definitions signatures at Typer
Fixes scala#14966
1 parent 2f0fd88 commit 6df4411

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
@@ -2167,10 +2167,12 @@ import transform.SymUtils._
21672167
else
21682168
"Name clash between inherited members"
21692169

2170-
em"""$clashDescription:
2171-
|${previousDecl.showDcl} ${symLocation(previousDecl)} and
2172-
|${decl.showDcl} ${symLocation(decl)}
2173-
|""" + details
2170+
atPhase(typerPhase) {
2171+
em"""$clashDescription:
2172+
|${previousDecl.showDcl} ${symLocation(previousDecl)} and
2173+
|${decl.showDcl} ${symLocation(decl)}
2174+
|"""
2175+
} + details
21742176
}
21752177
def explain = ""
21762178
}

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)