File tree Expand file tree Collapse file tree 4 files changed +40
-5
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 4 files changed +40
-5
lines changed Original file line number Diff line number Diff line change @@ -188,9 +188,17 @@ object NameOps {
188188 }
189189 }
190190
191- /** Do two target names match? An empty target name matchws any other name. */
191+ /** Do two target names match? An empty target name matches any other name.
192+ * Target names match if their simple names compare equal,
193+ * if they belong to the same term or type namespace,
194+ * and it's not the case that only one is a field name.
195+ */
192196 def matchesTargetName (other : Name ) =
193- name == other || name.isEmpty || other.isEmpty
197+ name.isEmpty
198+ || other.isEmpty
199+ || name.isTermName == other.isTermName
200+ && name.is(NameKinds .FieldName ) == other.is(NameKinds .FieldName )
201+ && name.toSimpleName == other.toSimpleName
194202
195203 private def functionSuffixStart : Int =
196204 val first = name.firstPart
Original file line number Diff line number Diff line change @@ -1344,11 +1344,12 @@ trait Checking {
13441344
13451345 /** Check that class does not declare same symbol twice */
13461346 def checkNoDoubleDeclaration (cls : Symbol )(using Context ): Unit =
1347- val seen = new mutable.HashMap [Name , List [Symbol ]].withDefaultValue(Nil )
1347+ val seen = new mutable.HashMap [String , List [Symbol ]].withDefaultValue(Nil )
13481348 typr.println(i " check no double declarations $cls" )
13491349
13501350 def checkDecl (decl : Symbol ): Unit =
1351- for other <- seen(decl.name) if decl.name != nme.ERROR && ! decl.isAbsent() && ! other.isAbsent() do
1351+ val key = decl.name.toString
1352+ for other <- seen(key) if decl.name != nme.ERROR && ! decl.isAbsent() && ! other.isAbsent() do
13521353 typr.println(i " conflict? $decl $other" )
13531354 def javaFieldMethodPair =
13541355 decl.is(JavaDefined ) && other.is(JavaDefined ) &&
@@ -1365,7 +1366,7 @@ trait Checking {
13651366 report.error(em " two or more overloaded variants of $decl have default arguments " , decl.srcPos)
13661367 decl.resetFlag(HasDefaultParams )
13671368 if ! excludeFromDoubleDeclCheck(decl) then
1368- seen(decl.name) = decl :: seen( decl.name)
1369+ seen(key) ::= decl
13691370
13701371 cls.info.decls.foreach(checkDecl)
13711372 cls.info match
Original file line number Diff line number Diff line change 1+ import annotation .*
2+
3+ case class StaticBinding (v : String ) {
4+ private def copy$default$1 (): String = ??? // error
5+ }
6+
7+ case class DynamicBinding (v : String ):
8+ @ targetName(" copy$default$1" )
9+ private def dynamo (): String = ??? // TODO
10+
11+ @ main def Demo =
12+ val b = StaticBinding (" test" )
13+ println(b)
Original file line number Diff line number Diff line change 1+ //> using options -Ycheck:mixin
2+
3+ object Diagnostic :
4+ trait OriginWarning (val origin : String ):
5+ self : Warning =>
6+ object OriginWarning :
7+ val NoOrigin = " ..."
8+
9+ class LintWarning (msg : String , origin : String = OriginWarning .NoOrigin )
10+ extends Warning (msg), OriginWarning (origin)
11+
12+ class Warning (msg : String ) extends Diagnostic (msg)
13+ class Diagnostic (val msg : String )
You can’t perform that action at this time.
0 commit comments