Skip to content

Commit 0cdc6ac

Browse files
committed
Overcome Name comparison hurdles
1 parent 68396ca commit 0cdc6ac

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

‎compiler/src/dotty/tools/dotc/core/NameOps.scala‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ object NameOps{
190190

191191
/** Do two target names match? An empty target name matchws any other name. */
192192
defmatchesTargetName(other: Name) =
193-
name == other || name.isEmpty || other.isEmpty
193+
name.toSimpleName== other.toSimpleName|| name.isEmpty || other.isEmpty
194194

195195
privatedeffunctionSuffixStart:Int=
196196
valfirst= name.firstPart

‎compiler/src/dotty/tools/dotc/typer/Checking.scala‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,11 +1342,12 @@ trait Checking{
13421342

13431343
/** Check that class does not declare same symbol twice */
13441344
defcheckNoDoubleDeclaration(cls: Symbol)(usingContext):Unit=
1345-
valseen=new mutable.HashMap[Name, List[Symbol]].withDefaultValue(Nil)
1345+
valseen=new mutable.HashMap[String, List[Symbol]].withDefaultValue(Nil)
13461346
typr.println(i"check no double declarations $cls")
13471347

13481348
defcheckDecl(decl: Symbol):Unit=
1349-
for other <- seen(decl.name) if decl.name != nme.ERROR&&!decl.isAbsent() &&!other.isAbsent() do
1349+
valkey= decl.name.toString
1350+
for other <- seen(key) if decl.name != nme.ERROR&&!decl.isAbsent() &&!other.isAbsent() do
13501351
typr.println(i"conflict? $decl$other")
13511352
defjavaFieldMethodPair=
13521353
decl.is(JavaDefined) && other.is(JavaDefined) &&
@@ -1363,7 +1364,7 @@ trait Checking{
13631364
report.error(em"two or more overloaded variants of $decl have default arguments", decl.srcPos)
13641365
decl.resetFlag(HasDefaultParams)
13651366
if!excludeFromDoubleDeclCheck(decl) then
1366-
seen(decl.name) = decl :: seen(decl.name)
1367+
seen(key) ::=decl
13671368

13681369
cls.info.decls.foreach(checkDecl)
13691370
cls.info match

‎tests/neg/i19274.scala‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
importannotation.*
2+
3+
caseclassStaticBinding(v: String){
4+
privatedefcopy$default$1():String=???// error
5+
}
6+
7+
caseclassDynamicBinding(v: String):
8+
@targetName("copy$default$1")
9+
privatedefdynamo():String=???// TODO
10+
11+
@main defDemo=
12+
valb=StaticBinding("test")
13+
println(b)

0 commit comments

Comments
(0)