Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8dc911b

Browse files
committed
Overcome Name comparison hurdles
1 parent68396ca commit8dc911b

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ 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.isEmpty|| other.isEmpty
194+
|| name.isTermName== other.isTermName&& name.toSimpleName== other.toSimpleName
194195

195196
privatedeffunctionSuffixStart:Int=
196197
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.infomatch

‎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+
@maindefDemo=
12+
valb=StaticBinding("test")
13+
println(b)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp