Skip to content

Commit

Permalink
Merge pull request #10718 from som-snytt/audit/xmigration
Browse files Browse the repository at this point in the history
Tweak the scala3-migration help about Xmigration [ci: last-only]
  • Loading branch information
lrytz committed Mar 17, 2024
2 parents a71db17 + 321fb82 commit 82268cc
Show file tree
Hide file tree
Showing 31 changed files with 104 additions and 104 deletions.
30 changes: 15 additions & 15 deletions src/compiler/scala/tools/nsc/Reporting.scala
Expand Up @@ -187,21 +187,21 @@ trait Reporting extends internal.Reporting { self: ast.Positions with Compilatio
else warning.msg
}

def ifNonEmpty(kind: String, filter: String) = if (filter.nonEmpty) s", $kind=$filter" else ""
def filterHelp =
s"msg=<part of the message>, cat=${warning.category.name}" +
ifNonEmpty("site", warning.site) +
(warning match {
case Message.Deprecation(_, _, _, origin, version, _) =>
ifNonEmpty("origin", origin) + ifNonEmpty("version", version.filterString)
case _ => ""
})
def scala3migration(isError: Boolean) =
if (isError && warning.category == WarningCategory.Scala3Migration)
"\nScala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings."
else ""
def helpMsg(kind: String, isError: Boolean = false) =
s"$quickfixed${scala3migration(isError)}\nApplicable -Wconf / @nowarn filters for this $kind: $filterHelp"
def helpMsg(level: String, isError: Boolean = false) = {
def ifNonEmpty(kind: String, filter: String) = if (filter.nonEmpty) s", $kind=$filter" else ""
def maybeSite = ifNonEmpty("site", warning.site)
def maybeOrigin = warning match {
case Message.Deprecation(_, _, _, origin, version, _) =>
ifNonEmpty("origin", origin) + ifNonEmpty("version", version.filterString)
case _ => ""
}
def filterHelp = s"msg=<part of the message>, cat=${warning.category.name}${maybeSite}${maybeOrigin}"
def scala3migration =
if (isError && warning.category == WarningCategory.Scala3Migration)
"\nScala 3 migration messages are issued as errors under -Xsource:3. Use -Wconf or @nowarn to demote them to warnings or suppress."
else ""
s"$quickfixed$scala3migration\nApplicable -Wconf / @nowarn filters for this $level: $filterHelp"
}

action match {
case Action.Error => reporter.error(warning.pos, helpMsg("fatal warning", isError = true), warning.actions)
Expand Down
2 changes: 1 addition & 1 deletion test/files/neg/case-cross.check
@@ -1,5 +1,5 @@
case-cross.scala:5: error: access modifiers for `apply` method are copied from the case class constructor under Scala 3 (or with -Xsource-features:case-apply-copy-access)
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
Scala 3 migration messages are issued as errors under -Xsource:3. Use -Wconf or @nowarn to demote them to warnings or suppress.
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=C.apply
case class C private (c: Int) {
^
Expand Down
2 changes: 1 addition & 1 deletion test/files/neg/deprecated-annots.check
@@ -1,5 +1,5 @@
deprecated-annots.scala:9: error: @scala.annotation.elidable is ignored in Scala 3
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
Scala 3 migration messages are issued as errors under -Xsource:3. Use -Wconf or @nowarn to demote them to warnings or suppress.
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=D
@annotation.elidable(42)
^
Expand Down
6 changes: 3 additions & 3 deletions test/files/neg/dotless-targs-a.check
@@ -1,15 +1,15 @@
dotless-targs-a.scala:4: error: type application is not allowed for infix operators [quickfixable]
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
Scala 3 migration messages are issued as errors under -Xsource:3. Use -Wconf or @nowarn to demote them to warnings or suppress.
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration
def fn2 = List apply[Int] 2
^
dotless-targs-a.scala:9: error: type application is not allowed for infix operators [quickfixable]
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
Scala 3 migration messages are issued as errors under -Xsource:3. Use -Wconf or @nowarn to demote them to warnings or suppress.
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration
def h1 = List apply[List[Int]] (List(1), List(2)) mapConserve[List[Any]] (x => x)
^
dotless-targs-a.scala:9: error: type application is not allowed for infix operators [quickfixable]
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
Scala 3 migration messages are issued as errors under -Xsource:3. Use -Wconf or @nowarn to demote them to warnings or suppress.
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration
def h1 = List apply[List[Int]] (List(1), List(2)) mapConserve[List[Any]] (x => x)
^
Expand Down
6 changes: 3 additions & 3 deletions test/files/neg/dotless-targs-b.check
@@ -1,15 +1,15 @@
dotless-targs-b.scala:4: error: type application is not allowed for infix operators [quickfixable]
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
Scala 3 migration messages are issued as errors under -Xsource:3. Use -Wconf or @nowarn to demote them to warnings or suppress.
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration
def fn2 = List apply[Int] 2
^
dotless-targs-b.scala:9: error: type application is not allowed for infix operators [quickfixable]
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
Scala 3 migration messages are issued as errors under -Xsource:3. Use -Wconf or @nowarn to demote them to warnings or suppress.
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration
def h1 = List apply[List[Int]] (List(1), List(2)) mapConserve[List[Any]] (x => x)
^
dotless-targs-b.scala:9: error: type application is not allowed for infix operators [quickfixable]
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
Scala 3 migration messages are issued as errors under -Xsource:3. Use -Wconf or @nowarn to demote them to warnings or suppress.
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration
def h1 = List apply[List[Int]] (List(1), List(2)) mapConserve[List[Any]] (x => x)
^
Expand Down
8 changes: 4 additions & 4 deletions test/files/neg/for-comprehension-val.check
Expand Up @@ -11,22 +11,22 @@ for-comprehension-val.scala:12: error: `val` keyword in for comprehension is uns
for (z <- 1 to 2 ; val x <- 1 to 5 ; val y = x) yield x+y // fail
^
for-comprehension-val.scala:5: error: `val` keyword in for comprehension is unsupported: instead, bind the value without `val` [quickfixable]
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
Scala 3 migration messages are issued as errors under -Xsource:3. Use -Wconf or @nowarn to demote them to warnings or suppress.
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration
for (x <- 1 to 5 ; val y = x) yield x+y // fail
^
for-comprehension-val.scala:7: error: `val` keyword in for comprehension is unsupported: instead, bind the value without `val` [quickfixable]
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
Scala 3 migration messages are issued as errors under -Xsource:3. Use -Wconf or @nowarn to demote them to warnings or suppress.
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration
for (val x <- 1 to 5 ; val y = x) yield x+y // fail
^
for-comprehension-val.scala:10: error: `val` keyword in for comprehension is unsupported: instead, bind the value without `val` [quickfixable]
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
Scala 3 migration messages are issued as errors under -Xsource:3. Use -Wconf or @nowarn to demote them to warnings or suppress.
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration
for (z <- 1 to 2 ; x <- 1 to 5 ; val y = x) yield x+y // fail
^
for-comprehension-val.scala:12: error: `val` keyword in for comprehension is unsupported: instead, bind the value without `val` [quickfixable]
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
Scala 3 migration messages are issued as errors under -Xsource:3. Use -Wconf or @nowarn to demote them to warnings or suppress.
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration
for (z <- 1 to 2 ; val x <- 1 to 5 ; val y = x) yield x+y // fail
^
Expand Down
2 changes: 1 addition & 1 deletion test/files/neg/implicit-any2stringadd-migration.check
@@ -1,5 +1,5 @@
implicit-any2stringadd-migration.scala:4: error: Converting to String for concatenation is not supported in Scala 3 (or with -Xsource-features:any2stringadd).
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
Scala 3 migration messages are issued as errors under -Xsource:3. Use -Wconf or @nowarn to demote them to warnings or suppress.
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=scala.Predef.any2stringadd
true + "what"
^
Expand Down
2 changes: 1 addition & 1 deletion test/files/neg/nested-class-shadowing-removal.check
@@ -1,5 +1,5 @@
nested-class-shadowing-removal.scala:9: error: shadowing a nested class of a parent is deprecated but class Status shadows class Status defined in trait Core; rename the class to something else
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
Scala 3 migration messages are issued as errors under -Xsource:3. Use -Wconf or @nowarn to demote them to warnings or suppress.
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=Ext.Status
class Status extends super.Status
^
Expand Down
8 changes: 4 additions & 4 deletions test/files/neg/nullary-override-3a.check
@@ -1,24 +1,24 @@
nullary-override-3a.scala:4: error: method with a single empty parameter list overrides method x in class A defined without a parameter list
def x: Int (defined in class A) [quickfixable]
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
Scala 3 migration messages are issued as errors under -Xsource:3. Use -Wconf or @nowarn to demote them to warnings or suppress.
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=B
class B extends A { override def x(): Int = 4 }
^
nullary-override-3a.scala:16: error: method with a single empty parameter list overrides method x in trait T1 defined without a parameter list
def x: String (defined in trait T1) [quickfixable]
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
Scala 3 migration messages are issued as errors under -Xsource:3. Use -Wconf or @nowarn to demote them to warnings or suppress.
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=Mix12b
class Mix12b extends T1 with T2 { override def x() = "12b" }
^
nullary-override-3a.scala:18: error: method without a parameter list overrides method x in trait T2 defined with a single empty parameter list
def x(): String (defined in trait T2) [quickfixable]
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
Scala 3 migration messages are issued as errors under -Xsource:3. Use -Wconf or @nowarn to demote them to warnings or suppress.
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=Mix21a
class Mix21a extends T2 with T1 { override def x = "21a" }
^
nullary-override-3a.scala:19: error: method with a single empty parameter list overrides method x in trait T1 defined without a parameter list
def x: String (defined in trait T1) [quickfixable]
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
Scala 3 migration messages are issued as errors under -Xsource:3. Use -Wconf or @nowarn to demote them to warnings or suppress.
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=Mix21b
class Mix21b extends T2 with T1 { override def x() = "21b" }
^
Expand Down
4 changes: 2 additions & 2 deletions test/files/neg/nullary-override-3b.check
@@ -1,12 +1,12 @@
nullary-override-3b.scala:6: error: method without a parameter list overrides method x in class P defined with a single empty parameter list
def x(): Int (defined in class P) [quickfixable]
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
Scala 3 migration messages are issued as errors under -Xsource:3. Use -Wconf or @nowarn to demote them to warnings or suppress.
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=Q
class Q extends P { override def x: Int = 4 }
^
nullary-override-3b.scala:11: error: method without a parameter list overrides method x in trait T2 defined with a single empty parameter list
def x(): String (defined in trait T2) [quickfixable]
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
Scala 3 migration messages are issued as errors under -Xsource:3. Use -Wconf or @nowarn to demote them to warnings or suppress.
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=Mix12a
class Mix12a extends T1 with T2 { override def x = "12a" }
^
Expand Down
2 changes: 1 addition & 1 deletion test/files/neg/parens-for-params.check
@@ -1,6 +1,6 @@
parens-for-params.scala:5: error: parentheses are required around the parameter of a lambda
Use '-Wconf:msg=lambda-parens:s' to silence this warning. [quickfixable]
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
Scala 3 migration messages are issued as errors under -Xsource:3. Use -Wconf or @nowarn to demote them to warnings or suppress.
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration
x: Int => x * 2
^
Expand Down
8 changes: 4 additions & 4 deletions test/files/neg/t11921-alias.check
Expand Up @@ -3,7 +3,7 @@ it is both defined in the enclosing object O and inherited in the enclosing clas
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.TT`.
Or use `-Wconf:msg=legacy-binding:s` to silence this warning. [quickfixable]
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
Scala 3 migration messages are issued as errors under -Xsource:3. Use -Wconf or @nowarn to demote them to warnings or suppress.
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=t2.O.D.n.x
def n(x: TT) = x // ambiguous
^
Expand All @@ -12,7 +12,7 @@ it is both defined in the enclosing class B and inherited in the enclosing anony
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.c`.
Or use `-Wconf:msg=legacy-binding:s` to silence this warning. [quickfixable]
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
Scala 3 migration messages are issued as errors under -Xsource:3. Use -Wconf or @nowarn to demote them to warnings or suppress.
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=t4.B.a
def n = c // ambiguous
^
Expand All @@ -21,7 +21,7 @@ it is both defined in the enclosing method m and inherited in the enclosing anon
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.name`.
Or use `-Wconf:msg=legacy-binding:s` to silence this warning. [quickfixable]
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
Scala 3 migration messages are issued as errors under -Xsource:3. Use -Wconf or @nowarn to demote them to warnings or suppress.
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=t6.Test.m
println(name)
^
Expand All @@ -30,7 +30,7 @@ it is both defined in the enclosing method m and inherited in the enclosing anon
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.name`.
Or use `-Wconf:msg=legacy-binding:s` to silence this warning. [quickfixable]
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
Scala 3 migration messages are issued as errors under -Xsource:3. Use -Wconf or @nowarn to demote them to warnings or suppress.
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=t7.Test.m
println(name)
^
Expand Down
2 changes: 1 addition & 1 deletion test/files/neg/t11921.check
Expand Up @@ -8,7 +8,7 @@ it is both defined in the enclosing method lazyMap and inherited in the enclosin
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.coll`.
Or use `-Wconf:msg=legacy-binding:s` to silence this warning. [quickfixable]
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
Scala 3 migration messages are issued as errors under -Xsource:3. Use -Wconf or @nowarn to demote them to warnings or suppress.
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=C.lazyMap
def iterator = coll.iterator.map(f) // coll is ambiguous
^
Expand Down

0 comments on commit 82268cc

Please sign in to comment.