Skip to content

Commit

Permalink
Use Arabic numerals in compiler error summary [ci: last-only] (#8578)
Browse files Browse the repository at this point in the history
Use Arabic numerals in compiler error summary [ci: last-only]
  • Loading branch information
lrytz committed Dec 9, 2019
2 parents 049417e + 5c5582c commit 165b64d
Show file tree
Hide file tree
Showing 1,190 changed files with 1,421 additions and 1,432 deletions.
19 changes: 8 additions & 11 deletions src/compiler/scala/tools/nsc/Reporting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ trait Reporting extends internal.Reporting { self: ast.Positions with Compilatio
class PerRunReporting extends PerRunReportingBase {
/** Collects for certain classes of warnings during this run. */
private class ConditionalWarning(what: String, doReport: Boolean, setting: Settings#Setting) {
def this(what: String, booleanSetting: Settings#BooleanSetting) {
def this(what: String, booleanSetting: Settings#BooleanSetting) =
this(what, booleanSetting.value, booleanSetting)
}
val warnings = mutable.LinkedHashMap[Position, (String, String)]()
def warn(pos: Position, msg: String, since: String = "") =
if (doReport) reporter.warning(pos, msg)
Expand All @@ -52,27 +51,25 @@ trait Reporting extends internal.Reporting { self: ast.Positions with Compilatio
val deprecationSummary = sinceAndAmount.size > 1
sinceAndAmount.foreach { case (since, numWarnings) =>
val warningsSince = if (since.nonEmpty) s" (since $since)" else ""
val warningVerb = if (numWarnings == 1) "was" else "were"
val warningCount = countElementsAsString(numWarnings, s"$what warning")
val warningCount = countElementsAsString(numWarnings, what)
val rerun = if (deprecationSummary) "" else reporter.rerunWithDetails(setting, setting.name)
reporter.warning(NoPosition, s"there ${warningVerb} ${warningCount}${warningsSince}${rerun}")
reporter.warning(NoPosition, s"$warningCount$warningsSince$rerun")
}
if (deprecationSummary) {
val numWarnings = warnings.size
val warningVerb = if (numWarnings == 1) "was" else "were"
val warningCount = countElementsAsString(numWarnings, s"$what warning")
val warningCount = countElementsAsString(numWarnings, what)
val rerun = reporter.rerunWithDetails(setting, setting.name)
reporter.warning(NoPosition, s"there ${warningVerb} ${warningCount} in total${rerun}")
reporter.warning(NoPosition, s"$warningCount in total$rerun")
}
}
}

// This change broke sbt; I gave it the thrilling name of uncheckedWarnings0 so
// as to recover uncheckedWarnings for its ever-fragile compiler interface.
private val _deprecationWarnings = new ConditionalWarning("deprecation", settings.deprecation)
private val _uncheckedWarnings = new ConditionalWarning("unchecked", settings.unchecked)
private val _featureWarnings = new ConditionalWarning("feature", settings.feature)
private val _inlinerWarnings = new ConditionalWarning("inliner", !settings.optWarningsSummaryOnly, settings.optWarnings)
private val _uncheckedWarnings = new ConditionalWarning("unchecked warning", settings.unchecked)
private val _featureWarnings = new ConditionalWarning("feature warning", settings.feature)
private val _inlinerWarnings = new ConditionalWarning("inliner warning", !settings.optWarningsSummaryOnly, settings.optWarnings)
private val _allConditionalWarnings = List(_deprecationWarnings, _uncheckedWarnings, _featureWarnings, _inlinerWarnings)

// TODO: remove in favor of the overload that takes a Symbol, give that argument a default (NoSymbol)
Expand Down
6 changes: 3 additions & 3 deletions src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class ConsoleReporter(val settings: Settings, val reader: BufferedReader, val wr
def doReport(pos: Position, msg: String, severity: Severity): Unit = display(pos, msg, severity)

override def finish(): Unit = {
import reflect.internal.util.StringOps.{countElementsAsString => countAs}
if (hasWarnings) echo(s"${countAs(warningCount, WARNING.toString.toLowerCase)} found")
if (hasErrors) echo(s"${countAs(errorCount, ERROR.toString.toLowerCase)} found")
import reflect.internal.util.StringOps.countElementsAsString
if (hasWarnings) echo(countElementsAsString(warningCount, WARNING.toString.toLowerCase))
if (hasErrors) echo(countElementsAsString(errorCount, ERROR.toString.toLowerCase))
super.finish()
}
}
15 changes: 3 additions & 12 deletions src/reflect/scala/reflect/internal/util/StringOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,13 @@ trait StringOps {
def countElementsAsString(n: Int, element: String): String =
n match {
case 0 => s"no ${element}s"
case 1 => s"one ${element}"
case 1 => s"1 ${element}"
case _ => s"${countAsString(n)} ${element}s"
}

/** Turns a count into a friendly English description if n<=4.
* Otherwise, a scary math representation.
/** String conversion.
*/
def countAsString(n: Int): String =
n match {
case 0 => "none"
case 1 => "one"
case 2 => "two"
case 3 => "three"
case 4 => "four"
case _ => n.toString
}
def countAsString(n: Int): String = Integer.toString(n)
}

object StringOps extends StringOps
2 changes: 1 addition & 1 deletion test/files/jvm/deprecation.check
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
warning: there were four deprecation warnings; re-run with -deprecation for details
warning: 4 deprecations; re-run with -deprecation for details
Note: deprecation/Use_2.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 changes: 1 addition & 1 deletion test/files/jvm/future-spec.check
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
warning: there were 5 deprecation warnings (since 2.13.0); re-run with -deprecation for details
warning: 5 deprecations (since 2.13.0); re-run with -deprecation for details
FutureTests$$anon$2: do not rethrow
FutureTests$$anon$3: expected
4 changes: 2 additions & 2 deletions test/files/jvm/interpreter.check
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ scala> case class Bar(n: Int)
class Bar

scala> implicit def foo2bar(foo: Foo) = Bar(foo.n)
warning: there was one feature warning; for details, enable `:setting -feature' or `:replay -feature'
warning: 1 feature warning; for details, enable `:setting -feature' or `:replay -feature'
def foo2bar(foo: Foo): Bar

scala> val bar: Bar = Foo(3)
Expand Down Expand Up @@ -261,7 +261,7 @@ scala> xs map (x => x)
val res6: Array[_] = Array(1, 2)

scala> xs map (x => (x, x))
warning: there was one feature warning; for details, enable `:setting -feature' or `:replay -feature'
warning: 1 feature warning; for details, enable `:setting -feature' or `:replay -feature'
val res7: Array[(_$1, _$1)] forSome { type _$1 } = Array((1,1), (2,2))

scala>
Expand Down
2 changes: 1 addition & 1 deletion test/files/jvm/manifests-new.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
warning: there were 7 deprecation warnings (since 2.13.0); re-run with -deprecation for details
warning: 7 deprecations (since 2.13.0); re-run with -deprecation for details
x=(), t=TypeTag[Unit], k=TypeRef, s=class Unit
x=true, t=TypeTag[Boolean], k=TypeRef, s=class Boolean
x=a, t=TypeTag[Char], k=TypeRef, s=class Char
Expand Down
2 changes: 1 addition & 1 deletion test/files/jvm/manifests-old.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
warning: there were 7 deprecation warnings (since 2.13.0); re-run with -deprecation for details
warning: 7 deprecations (since 2.13.0); re-run with -deprecation for details
x=(), m=Unit
x=true, m=Boolean
x=a, m=Char
Expand Down
2 changes: 1 addition & 1 deletion test/files/jvm/serialization-new.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
warning: there were four deprecation warnings (since 2.13.0); re-run with -deprecation for details
warning: 4 deprecations (since 2.13.0); re-run with -deprecation for details
a1 = Array[1,2,3]
_a1 = Array[1,2,3]
arrayEquals(a1, _a1): true
Expand Down
2 changes: 1 addition & 1 deletion test/files/jvm/serialization.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
warning: there were four deprecation warnings (since 2.13.0); re-run with -deprecation for details
warning: 4 deprecations (since 2.13.0); re-run with -deprecation for details
a1 = Array[1,2,3]
_a1 = Array[1,2,3]
arrayEquals(a1, _a1): true
Expand Down
2 changes: 1 addition & 1 deletion test/files/jvm/sync-var.check
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
warning: there was one deprecation warning (since 2.13.0); re-run with -deprecation for details
warning: 1 deprecation (since 2.13.0); re-run with -deprecation for details
50005000 50005000 true
4 changes: 2 additions & 2 deletions test/files/neg/FooMapView.check
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ FooMapView.scala:6: warning: overriding method stringPrefix in trait Iterable is
override def stringPrefix = "FooMapView"
^
error: No warnings can be incurred under -Werror.
one warning found
one error found
1 warning
1 error
2 changes: 1 addition & 1 deletion test/files/neg/abstract-class-2.check
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ abstract-class-2.scala:11: error: object creation impossible. Missing implementa
(Note that P.this.p.S1 does not match P2.this.S1: their prefixes (i.e., enclosing instances) differ)
object O2 extends S2 {
^
one error found
1 error
2 changes: 1 addition & 1 deletion test/files/neg/abstract-class-error.check
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ S.scala:1: error: class S needs to be abstract. Missing implementation for:
(Note that java.util.List does not match java.util.List[String]. To implement this raw type, use java.util.List[_])
class S extends J {
^
one error found
1 error
2 changes: 1 addition & 1 deletion test/files/neg/abstract-concrete-methods.check
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ abstract-concrete-methods.scala:7: error: class Outer2 needs to be abstract. Mis
(Note that This#Inner does not match Outer2#Inner: class Inner in class Outer2 is a subclass of trait Inner in trait Outer, but method parameter types must match exactly.)
class Outer2 extends Outer[Outer2] {
^
one error found
1 error
2 changes: 1 addition & 1 deletion test/files/neg/abstract-explaintypes.check
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ abstract-explaintypes.scala:11: error: type mismatch;
^
A <: A.this.T?
false
two errors found
2 errors
4 changes: 2 additions & 2 deletions test/files/neg/abstract-inaccessible.check
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ Classes which cannot access Bippy may be unable to override overrideMeAlso.
def overrideMeAlso(x: Map[Int, Set[Bippy]]) = x.keys.head
^
error: No warnings can be incurred under -Werror.
three warnings found
one error found
3 warnings
1 error
2 changes: 1 addition & 1 deletion test/files/neg/abstract-report.check
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ Missing implementations for 6 members. Stub implementations follow:

class Unimplemented extends scala.collection.IterableOps[String, List, List[String]] { }
^
one error found
1 error
2 changes: 1 addition & 1 deletion test/files/neg/abstract-report2.check
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ Missing implementations for 7 members. Stub implementations follow:

class Dingus extends Bippy[String, Set[Int], List[Int]]
^
four errors found
4 errors
2 changes: 1 addition & 1 deletion test/files/neg/abstract-vars.check
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ abstract-vars.scala:18: error: class Fail5 needs to be abstract. Missing impleme
(Note that an abstract var requires a getter in addition to the setter)
class Fail5 extends A {
^
5 errors found
5 errors
2 changes: 1 addition & 1 deletion test/files/neg/abstract.check
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ abstract.scala:9: error: type mismatch;
required: A.this.T
def foo5: T = baz().baz();
^
two errors found
2 errors
2 changes: 1 addition & 1 deletion test/files/neg/abstraction-from-volatile-type-error.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
abstraction-from-volatile-type-error.scala:9: error: illegal abstraction from value with volatile type a.Tv
val tv : a.Tv
^
one error found
1 error
2 changes: 1 addition & 1 deletion test/files/neg/accesses.check
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ protected[package p1] def f5(): Unit (defined in class A)
override should at least be protected[p1]
protected[p2] def f5(): Unit
^
four errors found
4 errors
2 changes: 1 addition & 1 deletion test/files/neg/accesses2.check
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ private[package p2] def f2(): Int (defined in class A)
override should not be private
private def f2(): Int = 1
^
three errors found
3 errors
4 changes: 2 additions & 2 deletions test/files/neg/aladdin1055.check
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ It would fail on the following input: (_ : this.<local child>)
def foo(t: A.T) = t match {
^
error: No warnings can be incurred under -Werror.
one warning found
one error found
1 warning
1 error
2 changes: 1 addition & 1 deletion test/files/neg/ambiguous-float-dots2.check
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ ambiguous-float-dots2.scala:3: error: identifier expected but '}' found.
ambiguous-float-dots2.scala:11: error: ';' expected but integer literal found.
1. + 2
^
two errors found
2 errors
2 changes: 1 addition & 1 deletion test/files/neg/ambiguous-same.check
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ it is both defined in object X and imported subsequently by
import X.x
x
^
one error found
1 error
2 changes: 1 addition & 1 deletion test/files/neg/annots-constant-neg.check
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,4 @@ Test.scala:73: error: annotation Ann4 is missing argument value
Test.scala:78: error: arguments to Java annotations or subclasses of ConstantAnnotation have to be supplied as named arguments
@Ann5(0) def v18 = 0 // err
^
37 errors found
37 errors
2 changes: 1 addition & 1 deletion test/files/neg/any-vs-anyref.check
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ any-vs-anyref.scala:27: error: type mismatch;
required: Quux{def g(x: Int): Int}
f(new Quux { def g(x: String) = x })
^
7 errors found
7 errors
2 changes: 1 addition & 1 deletion test/files/neg/anytrait.check
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ anytrait.scala:5: error: this statement is not allowed in universal trait extend
anytrait.scala:9: error: field definition is not allowed in universal trait extending from class Any
val y: T
^
three errors found
3 errors
2 changes: 1 addition & 1 deletion test/files/neg/anyval-anyref-parent.check
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ trait Foo5 extends AnyVal with Reffy // fail
anyval-anyref-parent.scala:12: error: only classes (not traits) are allowed to extend AnyVal
trait Foo5 extends AnyVal with Reffy // fail
^
6 errors found
6 errors
2 changes: 1 addition & 1 deletion test/files/neg/applydynamic_sip.check
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ error after rewriting to Test.this.bad2.updateDynamic("sel")
possible cause: maybe a wrong Dynamic method signature?
bad2.sel = 1
^
19 errors found
19 errors
2 changes: 1 addition & 1 deletion test/files/neg/bad-advice.check
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ bad-advice.scala:6: error: pattern type is incompatible with expected type;
required: Int
case Bip => true
^
one error found
1 error
2 changes: 1 addition & 1 deletion test/files/neg/badimport.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
badimport.scala:2: error: . expected
import collection
^
one error found
1 error
4 changes: 2 additions & 2 deletions test/files/neg/badtok-1-212.check
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ badtok-1-212.scala:10: error: empty character literal
badtok-1-212.scala:12: error: unclosed character literal
'
^
one warning found
four errors found
1 warning
4 errors
2 changes: 1 addition & 1 deletion test/files/neg/badtok-1.check
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ badtok-1.scala:19: error: unclosed character literal
badtok-1.scala:13: error: expected class or object definition
'abc'
^
10 errors found
10 errors
2 changes: 1 addition & 1 deletion test/files/neg/badtok-2.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
badtok-2.scala:3: error: unclosed quoted identifier
`x
^
one error found
1 error
2 changes: 1 addition & 1 deletion test/files/neg/badtok-3.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
badtok-3.scala:2: error: input ended while parsing XML
<x
^
one error found
1 error
2 changes: 1 addition & 1 deletion test/files/neg/byname-implicits-11.check
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ byname-implicits-11.scala:8: error: diverging implicit expansion for type Foo[In
starting with method foo in object Foo
implicitly[Foo[Int]]
^
one error found
1 error
2 changes: 1 addition & 1 deletion test/files/neg/byname-implicits-16.check
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ byname-implicits-16.scala:14: error: diverging implicit expansion for type Test.
starting with method expande in object Expand
implicitly[O[Z]]
^
one error found
1 error
2 changes: 1 addition & 1 deletion test/files/neg/byname-implicits-18.check
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ byname-implicits-18.scala:52: error: diverging implicit expansion for type Test.
starting with method tcGen in object Tc
implicitly[Tc[Bootstrap[Int]]]
^
one error found
1 error
2 changes: 1 addition & 1 deletion test/files/neg/byname-implicits-21.check
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ byname-implicits-21.scala:20: error: diverging implicit expansion for type Test.
starting with method fooGen in object Foo
implicitly[Foo[A[Unit]]]
^
one error found
1 error
2 changes: 1 addition & 1 deletion test/files/neg/byname-implicits-26.check
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ byname-implicits-26.scala:34: error: diverging implicit expansion for type Test.
starting with method fooGen in object Foo
implicitly[Foo[A]]
^
one error found
1 error
4 changes: 2 additions & 2 deletions test/files/neg/case-collision-multifile.check
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ two.scala:1: warning: Generated class hotDog differs only in case from HotDog (d
class hotDog
^
error: No warnings can be incurred under -Werror.
one warning found
one error found
1 warning
1 error
4 changes: 2 additions & 2 deletions test/files/neg/case-collision.check
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ case-collision.scala:16: warning: Generated class foo.wackO differs only in case
object wackO
^
error: No warnings can be incurred under -Werror.
6 warnings found
one error found
6 warnings
1 error
2 changes: 1 addition & 1 deletion test/files/neg/caseinherit.check
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ caseinherit.scala:4: error: case object Bippy has case ancestor foo.A, but case-
caseinherit.scala:11: error: case class Dingus has case ancestor foo.A, but case-to-case inheritance is prohibited. To overcome this limitation, use extractors to pattern match on non-leaf nodes.
case class Dingus(y: Int) extends Innocent
^
three errors found
3 errors
4 changes: 2 additions & 2 deletions test/files/neg/catch-all.check
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ catch-all.scala:8: warning: This catches all Throwables. If this is really inten
try { "warn" } catch { case _: RuntimeException => ; case x => }
^
error: No warnings can be incurred under -Werror.
three warnings found
one error found
3 warnings
1 error
4 changes: 2 additions & 2 deletions test/files/neg/check-dead.check
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ check-dead.scala:34: warning: dead code following this construct
throw new Exception // should warn
^
error: No warnings can be incurred under -Werror.
four warnings found
one error found
4 warnings
1 error
8 changes: 4 additions & 4 deletions test/files/neg/checksensible.check
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ checksensible.scala:97: warning: comparing values of types Unit and Int using `!
while ((c = in.read) != -1)
^
error: No warnings can be incurred under -Werror.
34 warnings found
one error found
34 warnings
1 error
#partest !java8
checksensible.scala:54: warning: symbol literal is deprecated; use Symbol("sym") instead
(1 != 'sym)
Expand Down Expand Up @@ -220,5 +220,5 @@ checksensible.scala:97: warning: comparing values of types Unit and Int using `!
while ((c = in.read) != -1)
^
error: No warnings can be incurred under -Werror.
38 warnings found
one error found
38 warnings
1 error
Loading

0 comments on commit 165b64d

Please sign in to comment.