Skip to content

Commit

Permalink
Demote the new ambiguity: nothing in 2.13.11, warn (not err) under Xs…
Browse files Browse the repository at this point in the history
…ource:3
  • Loading branch information
lrytz committed May 17, 2023
1 parent ca6b46f commit b8c58b1
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 9 deletions.
9 changes: 5 additions & 4 deletions src/compiler/scala/tools/nsc/typechecker/Contexts.scala
Expand Up @@ -1377,16 +1377,17 @@ trait Contexts { self: Analyzer =>
sm"""|it is both defined in the enclosing ${outer1.owner} and inherited in the enclosing $classDesc as $inherited1 (defined in ${inherited1.ownsString}$inherit)
|In Scala 2, symbols inherited from a superclass shadow symbols defined in an outer scope.
|Such references are ambiguous in Scala 3. To continue using the inherited symbol, write `this.${outer1.name}`."""
if (currentRun.isScala3)
Some(LookupAmbiguous(message))
else {
// For now (2.13.11), warn under Xsource:3. We'll consider warning by default (and erring in Xsource:3) in 2.13.12
if (currentRun.isScala3) {
// passing the message to `typedIdent` as attachment, we don't have the position here to report the warning
inherited.updateAttachment(LookupAmbiguityWarning(
sm"""|reference to ${outer1.name} is ambiguous;
|$message
|Or use `-Wconf:msg=legacy-binding:s` to silence this warning."""))
// Some(LookupAmbiguous(message)) // to make it an error in 2.13.12
None
} else
None
}
}
} else
Some(LookupAmbiguous(s"it is both defined in ${outer.owner} and available as ${inherited.fullLocationString}"))
Expand Down
2 changes: 1 addition & 1 deletion test/files/neg/t11921-alias.scala
@@ -1,4 +1,4 @@
// scalac: -Werror
// scalac: -Werror -Xsource:3

object t1 {
class C[T] { type TT = T }
Expand Down
2 changes: 1 addition & 1 deletion test/files/neg/t11921.scala
@@ -1,4 +1,4 @@

// scalac: -Xsource:3

class C {
def lazyMap[A, B](coll: Iterable[A], f: A => B) =
Expand Down
2 changes: 1 addition & 1 deletion test/files/neg/t11921b.scala
@@ -1,4 +1,4 @@
// scalac: -Werror
// scalac: -Werror -Xsource:3

object test1 {

Expand Down
2 changes: 1 addition & 1 deletion test/files/neg/t11921c.scala
@@ -1,4 +1,4 @@
// scalac: -Wconf:msg=legacy-binding:s
// scalac: -Wconf:msg=legacy-binding:s -Xsource:3

class C {
def lazyMap[A, B](coll: Iterable[A], f: A => B) =
Expand Down
2 changes: 1 addition & 1 deletion test/files/pos/t11921b.scala
@@ -1,4 +1,4 @@
// scalac: -Werror -Wconf:msg=legacy-binding:s
// scalac: -Werror -Wconf:msg=legacy-binding:s -Xsource:3

object test1 {

Expand Down
1 change: 1 addition & 0 deletions test/files/pos/t11921c.scala
@@ -1,3 +1,4 @@
// scalac: -Xsource:3

// test/scaladoc/resources/t5784.scala

Expand Down

0 comments on commit b8c58b1

Please sign in to comment.