Skip to content

Commit 28c2e67

Browse files
committed
move [quick fix available] to the end of the message
allow skipping it with `-quickfix:silent` make more error quickfixes available to `-quickfix` rewrite by using `runReporting.error` instead of `reporter.error`.
1 parent 5f46db7 commit 28c2e67

File tree

96 files changed

+355
-334
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+355
-334
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ trait Reporting extends internal.Reporting { self: ast.Positions with Compilatio
6969
if (settings.quickfix.isSetByUser && settings.quickfix.value.isEmpty) {
7070
globalError(s"Missing message filter for `-quickfix`; see `-quickfix:help` or use `-quickfix:any` to apply all available quick fixes.")
7171
Nil
72+
} else if (settings.quickFixSilent) {
73+
Nil
7274
} else {
7375
val parsed = settings.quickfix.value.map(WConf.parseFilter(_, rootDirPrefix))
7476
val msgs = parsed.collect { case Left(msg) => msg }
@@ -167,7 +169,7 @@ trait Reporting extends internal.Reporting { self: ast.Positions with Compilatio
167169

168170
val quickfixed = {
169171
if (!skipRewriteAction(action) && registerTextEdit(warning)) s"[rewritten by -quickfix] ${warning.msg}"
170-
else if (warning.actions.exists(_.edits.nonEmpty)) s"[quick fix available] ${warning.msg}"
172+
else if (warning.actions.exists(_.edits.nonEmpty) && !settings.quickFixSilent) s"${warning.msg} [quick fix available]"
171173
else warning.msg
172174
}
173175

@@ -359,7 +361,7 @@ trait Reporting extends internal.Reporting { self: ast.Positions with Compilatio
359361
def error(pos: Position, msg: String, actions: List[CodeAction]): Unit = {
360362
val quickfixed = {
361363
if (registerErrorTextEdit(pos, msg, actions)) s"[rewritten by -quickfix] $msg"
362-
else if (actions.exists(_.edits.nonEmpty)) s"[quick fix available] $msg"
364+
else if (actions.exists(_.edits.nonEmpty) && !settings.quickFixSilent) s"$msg [quick fix available]"
363365
else msg
364366
}
365367
reporter.error(pos, quickfixed, actions)

src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,11 @@ trait StandardScalaSettings { _: MutableSettings =>
6464
| -quickfix:msg=Auto-application apply quick fixes where the message contains "Auto-application"
6565
|
6666
|Use `-Wconf:any:warning-verbose` to display applicable message filters with each warning.
67+
|
68+
|Use `-quickfix:silent` to omit the `[quick fix available]` tag in compiler messages.
6769
|""".stripMargin),
6870
prepend = true)
71+
def quickFixSilent: Boolean = quickfix.value == List("silent")
6972
val release =
7073
ChoiceSetting("-release", "release", "Compile for a version of the Java API and target class file.", AllTargetVersions, normalizeTarget(javaSpecVersion))
7174
.withPostSetHook { setting =>

src/compiler/scala/tools/nsc/typechecker/Contexts.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1851,7 +1851,7 @@ trait Contexts { self: Analyzer =>
18511851

18521852
private[typechecker] class ImmediateReporter(_errorBuffer: mutable.LinkedHashSet[AbsTypeError] = null, _warningBuffer: mutable.LinkedHashSet[ContextWarning] = null) extends ContextReporter(_errorBuffer, _warningBuffer) {
18531853
override def makeBuffering: ContextReporter = new BufferingReporter(errorBuffer, warningBuffer)
1854-
def error(pos: Position, msg: String, actions: List[CodeAction]): Unit = reporter.error(pos, msg, actions)
1854+
def error(pos: Position, msg: String, actions: List[CodeAction]): Unit = runReporting.error(pos, msg, actions)
18551855
}
18561856

18571857
private[typechecker] class BufferingReporter(_errorBuffer: mutable.LinkedHashSet[AbsTypeError] = null, _warningBuffer: mutable.LinkedHashSet[ContextWarning] = null) extends ContextReporter(_errorBuffer, _warningBuffer) {

src/compiler/scala/tools/nsc/typechecker/RefChecks.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ abstract class RefChecks extends Transform {
320320
infoStringWithLocation(other) + (if (msg.isEmpty) "" else s"\n$indent") + msg + addendum
321321
}
322322
def emitOverrideError(fullmsg: String, actions: List[CodeAction] = Nil): Unit = {
323-
if (memberClass == clazz) reporter.error(member.pos, fullmsg, actions)
323+
if (memberClass == clazz) runReporting.error(member.pos, fullmsg, actions)
324324
else mixinOverrideErrors += MixinOverrideError(member, fullmsg)
325325
}
326326

test/files/jvm/interpreter.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class Bar
8888

8989
scala> implicit def foo2bar(foo: Foo) = Bar(foo.n)
9090
^
91-
warning: [quick fix available] Implicit definition should have explicit type (inferred Bar)
91+
warning: Implicit definition should have explicit type (inferred Bar) [quick fix available]
9292
warning: 1 feature warning; for details, enable `:setting -feature` or `:replay -feature`
9393
def foo2bar(foo: Foo): Bar
9494

test/files/neg/auto-application.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ auto-application.scala:5: error: Int does not take parameters
77
auto-application.scala:6: error: Int does not take parameters
88
("": Object).##()
99
^
10-
auto-application.scala:9: warning: [quick fix available] Auto-application to `()` is deprecated. Supply the empty argument list `()` explicitly to invoke method meth,
10+
auto-application.scala:9: warning: Auto-application to `()` is deprecated. Supply the empty argument list `()` explicitly to invoke method meth,
1111
or remove the empty argument list from its definition (Java-defined methods are exempt).
12-
In Scala 3, an unapplied method like this will be eta-expanded into a function.
12+
In Scala 3, an unapplied method like this will be eta-expanded into a function. [quick fix available]
1313
meth // warn, auto-application (of nilary methods) is deprecated
1414
^
1515
1 warning

test/files/neg/checksensible.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
checksensible.scala:54: warning: [quick fix available] symbol literal is deprecated; use Symbol("sym") instead
1+
checksensible.scala:54: warning: symbol literal is deprecated; use Symbol("sym") instead [quick fix available]
22
(1 != 'sym)
33
^
44
checksensible.scala:15: warning: comparing a fresh object using `eq` will always yield false

test/files/neg/deprecated_widening.check

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
1-
deprecated_widening.scala:5: warning: [quick fix available] Widening conversion from Int to Float is deprecated because it loses precision. Write `.toFloat` instead.
1+
deprecated_widening.scala:5: warning: Widening conversion from Int to Float is deprecated because it loses precision. Write `.toFloat` instead. [quick fix available]
22
val i_f: Float = i // deprecated
33
^
4-
deprecated_widening.scala:7: warning: [quick fix available] Widening conversion from Long to Float is deprecated because it loses precision. Write `.toFloat` instead.
4+
deprecated_widening.scala:7: warning: Widening conversion from Long to Float is deprecated because it loses precision. Write `.toFloat` instead. [quick fix available]
55
val l_f: Float = l // deprecated
66
^
7-
deprecated_widening.scala:8: warning: [quick fix available] Widening conversion from Long to Double is deprecated because it loses precision. Write `.toDouble` instead.
7+
deprecated_widening.scala:8: warning: Widening conversion from Long to Double is deprecated because it loses precision. Write `.toDouble` instead. [quick fix available]
88
val l_d: Double = l // deprecated
99
^
10-
deprecated_widening.scala:23: warning: [quick fix available] Widening conversion from Long to Float is deprecated because it loses precision. Write `.toFloat` instead.
10+
deprecated_widening.scala:23: warning: Widening conversion from Long to Float is deprecated because it loses precision. Write `.toFloat` instead. [quick fix available]
1111
val truncatedPosFloat:Float = 16777217L // deprecated
1212
^
13-
deprecated_widening.scala:26: warning: [quick fix available] Widening conversion from Long to Float is deprecated because it loses precision. Write `.toFloat` instead.
13+
deprecated_widening.scala:26: warning: Widening conversion from Long to Float is deprecated because it loses precision. Write `.toFloat` instead. [quick fix available]
1414
val truncatedNegFloat: Float = - 16777217L // deprecated
1515
^
16-
deprecated_widening.scala:30: warning: [quick fix available] Widening conversion from Int to Float is deprecated because it loses precision. Write `.toFloat` instead.
16+
deprecated_widening.scala:30: warning: Widening conversion from Int to Float is deprecated because it loses precision. Write `.toFloat` instead. [quick fix available]
1717
val truncatedPosFloatI:Float = 16777217 // deprecated
1818
^
19-
deprecated_widening.scala:33: warning: [quick fix available] Widening conversion from Int to Float is deprecated because it loses precision. Write `.toFloat` instead.
19+
deprecated_widening.scala:33: warning: Widening conversion from Int to Float is deprecated because it loses precision. Write `.toFloat` instead. [quick fix available]
2020
val truncatedNegFloatI: Float = - 16777217 // deprecated
2121
^
22-
deprecated_widening.scala:37: warning: [quick fix available] Widening conversion from Long to Double is deprecated because it loses precision. Write `.toDouble` instead.
22+
deprecated_widening.scala:37: warning: Widening conversion from Long to Double is deprecated because it loses precision. Write `.toDouble` instead. [quick fix available]
2323
val truncatedPosDouble:Double = 18014398509481985L // deprecated
2424
^
25-
deprecated_widening.scala:40: warning: [quick fix available] Widening conversion from Long to Double is deprecated because it loses precision. Write `.toDouble` instead.
25+
deprecated_widening.scala:40: warning: Widening conversion from Long to Double is deprecated because it loses precision. Write `.toDouble` instead. [quick fix available]
2626
val truncatedNegDouble: Double = - 18014398509481985L // deprecated
2727
^
28-
deprecated_widening.scala:47: warning: [quick fix available] Widening conversion from Int to Float is deprecated because it loses precision. Write `.toFloat` instead.
28+
deprecated_widening.scala:47: warning: Widening conversion from Int to Float is deprecated because it loses precision. Write `.toFloat` instead. [quick fix available]
2929
def literals = Set[Float](0x7fffffc0, 0x7ffffffd, 0x7ffffffe, 0x7fffffff)
3030
^
31-
deprecated_widening.scala:47: warning: [quick fix available] Widening conversion from Int to Float is deprecated because it loses precision. Write `.toFloat` instead.
31+
deprecated_widening.scala:47: warning: Widening conversion from Int to Float is deprecated because it loses precision. Write `.toFloat` instead. [quick fix available]
3232
def literals = Set[Float](0x7fffffc0, 0x7ffffffd, 0x7ffffffe, 0x7fffffff)
3333
^
34-
deprecated_widening.scala:47: warning: [quick fix available] Widening conversion from Int to Float is deprecated because it loses precision. Write `.toFloat` instead.
34+
deprecated_widening.scala:47: warning: Widening conversion from Int to Float is deprecated because it loses precision. Write `.toFloat` instead. [quick fix available]
3535
def literals = Set[Float](0x7fffffc0, 0x7ffffffd, 0x7ffffffe, 0x7fffffff)
3636
^
37-
deprecated_widening.scala:48: warning: [quick fix available] Widening conversion from Long to Float is deprecated because it loses precision. Write `.toFloat` instead.
37+
deprecated_widening.scala:48: warning: Widening conversion from Long to Float is deprecated because it loses precision. Write `.toFloat` instead. [quick fix available]
3838
def longingly = Set[Float](0x7fffffc0L, 0x7ffffffdL, 0x7ffffffeL, 0x7fffffffL)
3939
^
40-
deprecated_widening.scala:48: warning: [quick fix available] Widening conversion from Long to Float is deprecated because it loses precision. Write `.toFloat` instead.
40+
deprecated_widening.scala:48: warning: Widening conversion from Long to Float is deprecated because it loses precision. Write `.toFloat` instead. [quick fix available]
4141
def longingly = Set[Float](0x7fffffc0L, 0x7ffffffdL, 0x7ffffffeL, 0x7fffffffL)
4242
^
43-
deprecated_widening.scala:48: warning: [quick fix available] Widening conversion from Long to Float is deprecated because it loses precision. Write `.toFloat` instead.
43+
deprecated_widening.scala:48: warning: Widening conversion from Long to Float is deprecated because it loses precision. Write `.toFloat` instead. [quick fix available]
4444
def longingly = Set[Float](0x7fffffc0L, 0x7ffffffdL, 0x7ffffffeL, 0x7fffffffL)
4545
^
46-
deprecated_widening.scala:48: warning: [quick fix available] Widening conversion from Long to Float is deprecated because it loses precision. Write `.toFloat` instead.
46+
deprecated_widening.scala:48: warning: Widening conversion from Long to Float is deprecated because it loses precision. Write `.toFloat` instead. [quick fix available]
4747
def longingly = Set[Float](0x7fffffc0L, 0x7ffffffdL, 0x7ffffffeL, 0x7fffffffL)
4848
^
49-
deprecated_widening.scala:50: warning: [quick fix available] Widening conversion from Int to Float is deprecated because it loses precision. Write `.toFloat` instead.
49+
deprecated_widening.scala:50: warning: Widening conversion from Int to Float is deprecated because it loses precision. Write `.toFloat` instead. [quick fix available]
5050
def `pick one` = Set[Float](0x1000003, 0x1000004, 0x1000005)
5151
^
52-
deprecated_widening.scala:50: warning: [quick fix available] Widening conversion from Int to Float is deprecated because it loses precision. Write `.toFloat` instead.
52+
deprecated_widening.scala:50: warning: Widening conversion from Int to Float is deprecated because it loses precision. Write `.toFloat` instead. [quick fix available]
5353
def `pick one` = Set[Float](0x1000003, 0x1000004, 0x1000005)
5454
^
5555
deprecated_widening.scala:12: warning: method int2float in object Int is deprecated (since 2.13.1): Implicit conversion from Int to Float is dangerous because it loses precision. Write `.toFloat` instead.

test/files/neg/dotless-targs-a.check

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
dotless-targs-a.scala:4: error: [quick fix available] type application is not allowed for infix operators
1+
dotless-targs-a.scala:4: error: type application is not allowed for infix operators [quick fix available]
22
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
33
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration
44
def fn2 = List apply[Int] 2
55
^
6-
dotless-targs-a.scala:9: error: [quick fix available] type application is not allowed for infix operators
6+
dotless-targs-a.scala:9: error: type application is not allowed for infix operators [quick fix available]
77
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
88
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration
99
def h1 = List apply[List[Int]] (List(1), List(2)) mapConserve[List[Any]] (x => x)
1010
^
11-
dotless-targs-a.scala:9: error: [quick fix available] type application is not allowed for infix operators
11+
dotless-targs-a.scala:9: error: type application is not allowed for infix operators [quick fix available]
1212
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
1313
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration
1414
def h1 = List apply[List[Int]] (List(1), List(2)) mapConserve[List[Any]] (x => x)

test/files/neg/dotless-targs-b.check

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
dotless-targs-b.scala:4: error: [quick fix available] type application is not allowed for infix operators
1+
dotless-targs-b.scala:4: error: type application is not allowed for infix operators [quick fix available]
22
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
33
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration
44
def fn2 = List apply[Int] 2
55
^
6-
dotless-targs-b.scala:9: error: [quick fix available] type application is not allowed for infix operators
6+
dotless-targs-b.scala:9: error: type application is not allowed for infix operators [quick fix available]
77
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
88
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration
99
def h1 = List apply[List[Int]] (List(1), List(2)) mapConserve[List[Any]] (x => x)
1010
^
11-
dotless-targs-b.scala:9: error: [quick fix available] type application is not allowed for infix operators
11+
dotless-targs-b.scala:9: error: type application is not allowed for infix operators [quick fix available]
1212
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
1313
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration
1414
def h1 = List apply[List[Int]] (List(1), List(2)) mapConserve[List[Any]] (x => x)

test/files/neg/dotless-targs-ranged-a.check

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
dotless-targs-ranged-a.scala:4: warning: [quick fix available] type application is not allowed for infix operators
1+
dotless-targs-ranged-a.scala:4: warning: type application is not allowed for infix operators [quick fix available]
22
def fn2 = List apply[Int] 2
33
^
4-
dotless-targs-ranged-a.scala:9: warning: [quick fix available] type application is not allowed for infix operators
4+
dotless-targs-ranged-a.scala:9: warning: type application is not allowed for infix operators [quick fix available]
55
def h1 = List apply[List[Int]] (List(1), List(2)) mapConserve[List[Any]] (x => x)
66
^
7-
dotless-targs-ranged-a.scala:9: warning: [quick fix available] type application is not allowed for infix operators
7+
dotless-targs-ranged-a.scala:9: warning: type application is not allowed for infix operators [quick fix available]
88
def h1 = List apply[List[Int]] (List(1), List(2)) mapConserve[List[Any]] (x => x)
99
^
10-
dotless-targs-ranged-a.scala:13: warning: [quick fix available] type application is not allowed for infix operators
10+
dotless-targs-ranged-a.scala:13: warning: type application is not allowed for infix operators [quick fix available]
1111
def eval = 1 ->[Int] 2
1212
^
13-
dotless-targs-ranged-a.scala:14: warning: [quick fix available] type application is not allowed for infix operators
13+
dotless-targs-ranged-a.scala:14: warning: type application is not allowed for infix operators [quick fix available]
1414
def evil = new A() op [Int, String ] 42
1515
^
1616
dotless-targs-ranged-a.scala:9: warning: multiarg infix syntax looks like a tuple and will be deprecated

0 commit comments

Comments
 (0)