Skip to content

Commit 98a4234

Browse files
authored
Merge pull request scala#10481 from lrytz/WconfSiteAnon
Skip anonymous and placeholder symbols in Wconf site string
2 parents 344d99b + fdaaad1 commit 98a4234

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

src/compiler/scala/tools/nsc/Reporting.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,16 @@ trait Reporting extends internal.Reporting { self: ast.Positions with Compilatio
208208
}
209209

210210
private def siteName(sym: Symbol) = if (sym.exists) {
211+
def skipAnon(s: Symbol, res: Symbol): Symbol =
212+
if (s.isRootSymbol || s == NoSymbol) res
213+
else if (s.isAnonymousClass || s.isLocalDummy) skipAnon(s.effectiveOwner, s.effectiveOwner)
214+
else skipAnon(s.effectiveOwner, res)
211215
// Similar to fullNameString, but don't jump to enclosing class. Keep full chain of symbols.
212216
def impl(s: Symbol): String =
213217
if (s.isRootSymbol || s == NoSymbol) s.nameString
214218
else if (s.owner.isEffectiveRoot) s.nameString
215219
else impl(s.effectiveOwner) + "." + s.nameString
216-
impl(sym)
220+
impl(skipAnon(sym, sym))
217221
} else ""
218222

219223
override def deprecationWarning(pos: Position, msg: String, since: String, site: String, origin: String, actions: List[CodeAction] = Nil): Unit =

test/files/neg/t11921-alias.check

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ In Scala 2, symbols inherited from a superclass shadow symbols defined in an out
1313
Such references are ambiguous in Scala 3. To continue using the inherited symbol, write `this.c`.
1414
Or use `-Wconf:msg=legacy-binding:s` to silence this warning.
1515
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
16-
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=t4.B.a.$anon.n
16+
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=t4.B.a
1717
def n = c // ambiguous
1818
^
1919
t11921-alias.scala:57: error: reference to name is ambiguous;
@@ -22,7 +22,7 @@ In Scala 2, symbols inherited from a superclass shadow symbols defined in an out
2222
Such references are ambiguous in Scala 3. To continue using the inherited symbol, write `this.name`.
2323
Or use `-Wconf:msg=legacy-binding:s` to silence this warning.
2424
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
25-
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=t6.Test.m.$anon.<local $anon>
25+
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=t6.Test.m
2626
println(name)
2727
^
2828
t11921-alias.scala:67: error: reference to name is ambiguous;
@@ -31,7 +31,7 @@ In Scala 2, symbols inherited from a superclass shadow symbols defined in an out
3131
Such references are ambiguous in Scala 3. To continue using the inherited symbol, write `this.name`.
3232
Or use `-Wconf:msg=legacy-binding:s` to silence this warning.
3333
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
34-
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=t7.Test.m.$anon.<local $anon>
34+
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=t7.Test.m
3535
println(name)
3636
^
3737
4 errors

test/files/neg/t11921.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ In Scala 2, symbols inherited from a superclass shadow symbols defined in an out
99
Such references are ambiguous in Scala 3. To continue using the inherited symbol, write `this.coll`.
1010
Or use `-Wconf:msg=legacy-binding:s` to silence this warning.
1111
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
12-
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=C.lazyMap.$anon.iterator
12+
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=C.lazyMap
1313
def iterator = coll.iterator.map(f) // coll is ambiguous
1414
^
1515
2 errors

test/files/neg/t11921b.check

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ In Scala 2, symbols inherited from a superclass shadow symbols defined in an out
77
Such references are ambiguous in Scala 3. To continue using the inherited symbol, write `this.x`.
88
Or use `-Wconf:msg=legacy-binding:s` to silence this warning.
99
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
10-
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=test1.Test.D.<local D>
10+
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=test1.Test.D
1111
println(x) // error
1212
^
1313
t11921b.scala:15: error: reference to x is ambiguous;
@@ -16,7 +16,7 @@ In Scala 2, symbols inherited from a superclass shadow symbols defined in an out
1616
Such references are ambiguous in Scala 3. To continue using the inherited symbol, write `this.x`.
1717
Or use `-Wconf:msg=legacy-binding:s` to silence this warning.
1818
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
19-
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=test1.Test.f.$anon.<local $anon>
19+
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=test1.Test.f
2020
println(x) // error
2121
^
2222
t11921b.scala:26: error: reference to y is ambiguous;
@@ -25,7 +25,7 @@ In Scala 2, symbols inherited from a superclass shadow symbols defined in an out
2525
Such references are ambiguous in Scala 3. To continue using the inherited symbol, write `this.y`.
2626
Or use `-Wconf:msg=legacy-binding:s` to silence this warning.
2727
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
28-
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=test2.c.$anon.<local $anon>
28+
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=test2.c
2929
println(y) // error
3030
^
3131
t11921b.scala:38: error: reference to y is ambiguous;
@@ -34,7 +34,7 @@ In Scala 2, symbols inherited from a superclass shadow symbols defined in an out
3434
Such references are ambiguous in Scala 3. To continue using the inherited symbol, write `E.this.y`.
3535
Or use `-Wconf:msg=legacy-binding:s` to silence this warning.
3636
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
37-
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=test3.c.E.F.<local F>
37+
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=test3.c.E.F
3838
println(y) // error
3939
^
4040
t11921b.scala:65: error: reference to global is ambiguous;
@@ -43,7 +43,7 @@ In Scala 2, symbols inherited from a superclass shadow symbols defined in an out
4343
Such references are ambiguous in Scala 3. To continue using the inherited symbol, write `this.global`.
4444
Or use `-Wconf:msg=legacy-binding:s` to silence this warning.
4545
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
46-
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=D.<local D>
46+
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=D
4747
println(global) // error
4848
^
4949
t11921b.scala:75: error: reference to x is ambiguous;

0 commit comments

Comments
 (0)