From 1afdb3cb6c5830daf763438914bedb629adfa53f Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Sat, 25 Apr 2020 10:09:31 -0700 Subject: [PATCH] Warning summary respects -nowarn Previously, hasWarning meant a warning had been displayed (as opposed to counted). Since last refactor, it means counted, so warnings were summarized under -nowarn. Until 2.13.1, there was no summary under -nowarn. Let -nowarn mean -Xmaxwarns 0 (to mean show me no warnings) and additionally don't summarize any warnings (including erroring under -Werror). Named constants for Reporter.filter Test that suppression is relaxed in debug mode. Restore maxwarns after suppressing Scaladoc also touches nowarn ConsoleReporter respects nowarn, since PerRunReporting suppression mechanism has a checkpoint after typer, such that subsequent warnings are issued directly and therefore bump the warnings count. (cherry picked from commit 2a2f4169caab45ad69ce6599a970e07c3a26de08) --- src/compiler/scala/tools/nsc/Reporting.scala | 3 +- .../tools/nsc/reporters/ConsoleReporter.scala | 6 ++-- .../scala/tools/nsc/reporters/Reporter.scala | 27 ++++++-------- .../nsc/settings/StandardScalaSettings.scala | 2 +- .../scala/reflect/internal/Reporting.scala | 15 ++++---- .../scala/tools/nsc/interpreter/IMain.scala | 6 +++- .../tools/nsc/doc/ScaladocAnalyzer.scala | 11 ++++-- test/files/jvm/interpreter.check | 6 ---- test/files/neg/t11952.check | 3 ++ test/files/neg/t11952.scala | 10 ++++++ test/files/neg/t11952b.check | 16 +++++++++ test/files/neg/t11952b.scala | 10 ++++++ test/files/pos/t11952.scala | 10 ++++++ test/files/run/constrained-types.check | 4 --- .../run/reflection-magicsymbols-repl.check | 1 - test/files/run/repl-bare-expr.check | 18 ---------- .../run/repl-class-based-outer-pointers.check | 3 -- .../run/repl-no-imports-no-predef-power.check | 2 -- .../files/run/repl-no-imports-no-predef.check | 36 ------------------- test/files/run/repl-parens.check | 18 ---------- test/files/run/repl-power.check | 2 -- test/files/run/t4172.check | 1 - test/files/run/t4542.check | 3 -- test/files/run/t4594-repl-settings.check | 4 --- test/files/run/t4710.check | 1 - test/files/run/t6329_repl.check | 4 --- test/files/run/t6329_repl_bug.check | 1 - test/files/run/t7319.check | 3 -- test/files/run/t7747-repl.check | 36 ------------------- test/files/run/xMigration.check | 12 ------- test/scaladoc/run/t5527.scala | 23 ++++++------ 31 files changed, 101 insertions(+), 196 deletions(-) create mode 100644 test/files/neg/t11952.check create mode 100644 test/files/neg/t11952.scala create mode 100644 test/files/neg/t11952b.check create mode 100644 test/files/neg/t11952b.scala create mode 100644 test/files/pos/t11952.scala diff --git a/src/compiler/scala/tools/nsc/Reporting.scala b/src/compiler/scala/tools/nsc/Reporting.scala index c86d3de1c6..2005abc093 100644 --- a/src/compiler/scala/tools/nsc/Reporting.scala +++ b/src/compiler/scala/tools/nsc/Reporting.scala @@ -266,7 +266,8 @@ trait Reporting extends scala.reflect.internal.Reporting { self: ast.Positions w /** Has any macro expansion used a fallback during this run? */ var seenMacroExpansionsFallingBack = false - def summarizeErrors(): Unit = if (!reporter.hasErrors) { + // i.e., summarize warnings + def summarizeErrors(): Unit = if (!reporter.hasErrors && !settings.nowarn) { for (c <- summarizedWarnings.keys.toList.sortBy(_.name)) summarize(Action.WarningSummary, c) for (c <- summarizedInfos.keys.toList.sortBy(_.name)) diff --git a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala index e8b7339d82..e0f7e1c3f5 100644 --- a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala +++ b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala @@ -26,8 +26,10 @@ class ConsoleReporter(val settings: Settings, val reader: BufferedReader, val wr 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") + if (!settings.nowarn && hasWarnings) + echo(s"${countAs(warningCount, WARNING.toString.toLowerCase)} found") + if (hasErrors) + echo(s"${countAs(errorCount, ERROR.toString.toLowerCase)} found") super.finish() } } diff --git a/src/compiler/scala/tools/nsc/reporters/Reporter.scala b/src/compiler/scala/tools/nsc/reporters/Reporter.scala index ad3c5f8aba..51adc80204 100644 --- a/src/compiler/scala/tools/nsc/reporters/Reporter.scala +++ b/src/compiler/scala/tools/nsc/reporters/Reporter.scala @@ -97,19 +97,20 @@ abstract class FilteringReporter extends Reporter { private def maxErrors: Int = settings.maxerrs.value private def maxWarnings: Int = settings.maxwarns.value - private def noWarnings: Boolean = settings.nowarn.value - override def filter(pos: Position, msg: String, severity: Severity): Int = { + import internal.Reporter.{ERROR => Error, WARNING => Warning, _} def maxOk = severity match { - case internal.Reporter.ERROR => maxErrors < 0 || errorCount < maxErrors - case internal.Reporter.WARNING => !noWarnings && (maxWarnings < 0 || warningCount < maxWarnings) - case _ => true + case Error => maxErrors < 0 || errorCount < maxErrors + case Warning => maxWarnings < 0 || warningCount < maxWarnings + case _ => true } - if (!duplicateOk(pos, severity, msg)) { - notifySuppressed(pos, msg, severity) - 2 // don't count, don't display - } else if (!maxOk) 1 // count, but don't display - else 0 + // Invoked when an error or warning is filtered by position. + @inline def suppress = { + if (settings.prompt) doReport(pos, msg, severity) + else if (settings.debug) doReport(pos, s"[ suppressed ] $msg", severity) + Suppress + } + if (!duplicateOk(pos, severity, msg)) suppress else if (!maxOk) Count else Display } /** Returns `true` if the message should be reported. Messages are skipped if: @@ -139,12 +140,6 @@ abstract class FilteringReporter extends Reporter { } } - /* Invoked when an error or warning is filtered by position. */ - private def notifySuppressed(pos: Position, msg: String, severity: Severity): Unit = { - if (settings.prompt) doReport(pos, msg, severity) - else if (settings.debug) doReport(pos, "[ suppressed ] " + msg, severity) - } - override def reset(): Unit = { super.reset() positions.clear() diff --git a/src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala index a2c83c8092..53ca101fa1 100644 --- a/src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala @@ -51,7 +51,7 @@ trait StandardScalaSettings { _: MutableSettings => } val g = ChoiceSetting ("-g", "level", "Set level of generated debugging info.", List("none", "source", "line", "vars", "notailcalls"), "vars") val help = BooleanSetting ("-help", "Print a synopsis of standard options") - val nowarn = BooleanSetting ("-nowarn", "Generate no warnings.") + val nowarn = BooleanSetting ("-nowarn", "Generate no warnings.") withPostSetHook { s => if (s) maxwarns.value = 0 } val optimise: BooleanSetting // depends on post hook which mutates other settings val print = BooleanSetting ("-print", "Print program with Scala-specific features removed.") val target = ChoiceSettingForcedDefault ("-target", "target", "Target platform for object files. All JVM 1.5 - 1.7 targets are deprecated.", diff --git a/src/reflect/scala/reflect/internal/Reporting.scala b/src/reflect/scala/reflect/internal/Reporting.scala index 70f28ce6a5..5fa446d887 100644 --- a/src/reflect/scala/reflect/internal/Reporting.scala +++ b/src/reflect/scala/reflect/internal/Reporting.scala @@ -101,12 +101,9 @@ abstract class Reporter { // If `force`, INFO messages were always printed. Now, INFO messages are always printed. protected def info0(pos: Position, msg: String, severity: Severity, force: Boolean): Unit - /** Return - * - 0: count and display - * - 1: count only, don't display - * - 2: don't count, don't display - */ - def filter(pos: Position, msg: String, severity: Severity): Int = 0 + /** @return Reporter.Display, or override for Count, Suppress + */ + def filter(pos: Position, msg: String, severity: Severity): Int = Reporter.Display final def echo(msg: String): Unit = echo(util.NoPosition, msg) final def echo(pos: Position, msg: String): Unit = if (filter(pos, msg, INFO) == 0) info0(pos, msg, INFO, force = true) @@ -152,7 +149,11 @@ abstract class Reporter { } object Reporter { - sealed class Severity(val id: Int, override val toString: String) + final val Display = 0 // display and count toward hasWarnings + final val Count = 1 // no display but count toward hasWarnings + final val Suppress = 2 // no display, does not bump count for hasWarnings + + sealed abstract class Severity(val id: Int, override val toString: String) object INFO extends Severity(0, "INFO") object WARNING extends Severity(1, "WARNING") object ERROR extends Severity(2, "ERROR") diff --git a/src/repl/scala/tools/nsc/interpreter/IMain.scala b/src/repl/scala/tools/nsc/interpreter/IMain.scala index 775db606a6..bcdacfbd58 100644 --- a/src/repl/scala/tools/nsc/interpreter/IMain.scala +++ b/src/repl/scala/tools/nsc/interpreter/IMain.scala @@ -1275,6 +1275,7 @@ object IMain { private[interpreter] def withSuppressedSettings[A](settings: Settings, global: => Global)(body: => A): A = { import settings._ val wasWarning = !nowarn + val oldMaxWarn = maxwarns.value val noisy = List(Xprint, Ytyperdebug, browse) val current = (Xprint.value, Ytyperdebug.value, browse.value) val noisesome = wasWarning || noisy.exists(!_.isDefault) @@ -1289,7 +1290,10 @@ object IMain { Xprint.value = current._1 Ytyperdebug.value = current._2 browse.value = current._3 - if (wasWarning) nowarn.value = false + if (wasWarning) { + nowarn.value = false + maxwarns.value = oldMaxWarn + } // ctl-D in repl can result in no compiler val g = global if (g != null) { diff --git a/src/scaladoc/scala/tools/nsc/doc/ScaladocAnalyzer.scala b/src/scaladoc/scala/tools/nsc/doc/ScaladocAnalyzer.scala index fef6d11240..a1ddd8012b 100644 --- a/src/scaladoc/scala/tools/nsc/doc/ScaladocAnalyzer.scala +++ b/src/scaladoc/scala/tools/nsc/doc/ScaladocAnalyzer.scala @@ -135,9 +135,16 @@ abstract class ScaladocSyntaxAnalyzer[G <: Global](val global: G) extends Syntax import global.{ settings, Symbol } def parseComment(comment: DocComment) = { val nowarnings = settings.nowarn.value - settings.nowarn.value = true + val maxwarns = settings.maxwarns.value + if (!nowarnings) { + settings.nowarn.value = true + } try parseAtSymbol(comment.raw, comment.raw, comment.pos) - finally settings.nowarn.value = nowarnings + finally + if (!nowarnings) { + settings.nowarn.value = false + settings.maxwarns.value = maxwarns + } } override def internalLink(sym: Symbol, site: Symbol): Option[LinkTo] = None diff --git a/test/files/jvm/interpreter.check b/test/files/jvm/interpreter.check index b0e666bda3..d129a4ea6e 100644 --- a/test/files/jvm/interpreter.check +++ b/test/files/jvm/interpreter.check @@ -93,7 +93,6 @@ scala> case class Bar(n: Int) defined class Bar scala> implicit def foo2bar(foo: Foo) = Bar(foo.n) -warning: one feature warning; for details, enable `:setting -feature' or `:replay -feature' foo2bar: (foo: Foo)Bar scala> val bar: Bar = Foo(3) @@ -267,7 +266,6 @@ scala> xs map (x => x) res6: Array[_] = Array(1, 2) scala> xs map (x => (x, x)) -warning: one feature warning; for details, enable `:setting -feature' or `:replay -feature' res7: Array[(_$1, _$1)] forSome { type _$1 } = Array((1,1), (2,2)) scala> @@ -353,10 +351,6 @@ defined class Term scala> def f(e: Exp) = e match { // non-exhaustive warning here case _:Fact => 3 } -:18: warning: match may not be exhaustive. -It would fail on the following inputs: Exp(), Term() -def f(e: Exp) = e match { // non-exhaustive warning here - ^ f: (e: Exp)Int scala> :quit diff --git a/test/files/neg/t11952.check b/test/files/neg/t11952.check new file mode 100644 index 0000000000..45a9210979 --- /dev/null +++ b/test/files/neg/t11952.check @@ -0,0 +1,3 @@ +error: No warnings can be incurred under -Xfatal-warnings. +two warnings found +one error found diff --git a/test/files/neg/t11952.scala b/test/files/neg/t11952.scala new file mode 100644 index 0000000000..d404412123 --- /dev/null +++ b/test/files/neg/t11952.scala @@ -0,0 +1,10 @@ +// scalac: -Xfatal-warnings -Xlint -Xmaxwarns 0 +// +// nowarn should mean no warnings are emitted, +// irrespective of other flags, and also no +// warnings should be summarized. +// +class C { + def f = 1 → 2 + def g: Unit = 1 +} diff --git a/test/files/neg/t11952b.check b/test/files/neg/t11952b.check new file mode 100644 index 0000000000..b2e9fe6cc5 --- /dev/null +++ b/test/files/neg/t11952b.check @@ -0,0 +1,16 @@ +[running phase parser on t11952b.scala] +[running phase namer on t11952b.scala] +[running phase packageobjects on t11952b.scala] +[running phase typer on t11952b.scala] +[running phase patmat on t11952b.scala] +[running phase superaccessors on t11952b.scala] +[running phase extmethods on t11952b.scala] +[running phase pickler on t11952b.scala] +[running phase refchecks on t11952b.scala] +t11952b.scala:9: error: overriding method f in class C of type => String; + method f cannot override final member; + found : => scala.this.Int + required: => String + override def f: Int = 42 + ^ +one error found diff --git a/test/files/neg/t11952b.scala b/test/files/neg/t11952b.scala new file mode 100644 index 0000000000..004befd15d --- /dev/null +++ b/test/files/neg/t11952b.scala @@ -0,0 +1,10 @@ +// scalac: -Xfatal-warnings -Xlint -Ydebug +// +// Multiple errors at a location are shown under debug. +// +class C { + final def f: String = "hello, world" +} +class D extends C { + override def f: Int = 42 +} diff --git a/test/files/pos/t11952.scala b/test/files/pos/t11952.scala new file mode 100644 index 0000000000..c3b1b4e1f0 --- /dev/null +++ b/test/files/pos/t11952.scala @@ -0,0 +1,10 @@ +// scalac: -Xfatal-warnings -Xlint -nowarn +// +// nowarn should mean no warnings are emitted, +// irrespective of other flags, and also no +// warnings should be summarized. +// +class C { + def f = 1 → 2 + def g: Unit = 1 +} diff --git a/test/files/run/constrained-types.check b/test/files/run/constrained-types.check index 4f2c7015ec..7cb42182cb 100644 --- a/test/files/run/constrained-types.check +++ b/test/files/run/constrained-types.check @@ -69,11 +69,9 @@ scala> var four = "four" four: String = four scala> val four2 = m(four) // should have an existential bound -warning: one feature warning; for details, enable `:setting -feature' or `:replay -feature' four2: String @Annot(x) forSome { val x: String } = four scala> val four3 = four2 // should have the same type as four2 -warning: one feature warning; for details, enable `:setting -feature' or `:replay -feature' four3: String @Annot(x) forSome { val x: String } = four scala> val stuff = m("stuff") // should not crash @@ -96,7 +94,6 @@ scala> def m = { val y : String @Annot(x) = x y } // x should not escape the local scope with a narrow type -warning: one feature warning; for details, enable `:setting -feature' or `:replay -feature' m: String @Annot(x) forSome { val x: String } scala> @@ -110,7 +107,6 @@ scala> def n(y: String) = { } m("stuff".stripMargin) } // x should be existentially bound -warning: one feature warning; for details, enable `:setting -feature' or `:replay -feature' n: (y: String)String @Annot(x) forSome { val x: String } scala> diff --git a/test/files/run/reflection-magicsymbols-repl.check b/test/files/run/reflection-magicsymbols-repl.check index 750abfeaa1..bb47d2e164 100644 --- a/test/files/run/reflection-magicsymbols-repl.check +++ b/test/files/run/reflection-magicsymbols-repl.check @@ -19,7 +19,6 @@ scala> def test(n: Int): Unit = { val x = sig.asInstanceOf[MethodType].params.head println(x.info) } -warning: one feature warning; for details, enable `:setting -feature' or `:replay -feature' test: (n: Int)Unit scala> for (i <- 1 to 8) test(i) diff --git a/test/files/run/repl-bare-expr.check b/test/files/run/repl-bare-expr.check index f437e2fe4d..4cb313f068 100644 --- a/test/files/run/repl-bare-expr.check +++ b/test/files/run/repl-bare-expr.check @@ -1,32 +1,14 @@ scala> 2 ; 3 -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -2 ;; -^ res0: Int = 3 scala> { 2 ; 3 } -:12: warning: a pure expression does nothing in statement position; multiline expressions might require enclosing parentheses -{ 2 ; 3 } - ^ res1: Int = 3 scala> 5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Moooooo" } ; 30 ; def bippy = { 1 + 2 + 3 } ; bippy+88+11 -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Moooooo" } ; 30 ; def bippy = { -^ -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Moooooo" } ; 30 ; def bippy = { - ^ -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Moooooo" } ; 30 ; def bippy = { - ^ -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Moooooo" } ; 30 ; def bippy = { - ^ defined object Cow defined class Moo bippy: Int diff --git a/test/files/run/repl-class-based-outer-pointers.check b/test/files/run/repl-class-based-outer-pointers.check index 4a123aec92..0d6cf2debe 100644 --- a/test/files/run/repl-class-based-outer-pointers.check +++ b/test/files/run/repl-class-based-outer-pointers.check @@ -8,9 +8,6 @@ defined class Value defined object Value scala> class C { final case class Num(value: Double) } // here it should still warn -:11: warning: The outer reference in this type test cannot be checked at run time. -class C { final case class Num(value: Double) } // here it should still warn - ^ defined class C scala> :quit diff --git a/test/files/run/repl-no-imports-no-predef-power.check b/test/files/run/repl-no-imports-no-predef-power.check index a1b8060ff2..84fd238da1 100644 --- a/test/files/run/repl-no-imports-no-predef-power.check +++ b/test/files/run/repl-no-imports-no-predef-power.check @@ -7,11 +7,9 @@ Try :help or completions for vals._ and power._ scala> // guarding against "error: reference to global is ambiguous" scala> global.emptyValDef // "it is imported twice in the same scope by ..." -warning: one deprecation (since 2.11.0); for details, enable `:setting -deprecation' or `:replay -deprecation' res0: $r.global.noSelfType.type = private val _ = _ scala> val tp = ArrayClass[scala.util.Random] // magic with tags -warning: one feature warning; for details, enable `:setting -feature' or `:replay -feature' tp: $r.global.Type = Array[scala.util.Random] scala> tp.memberType(Array_apply) // evidence diff --git a/test/files/run/repl-no-imports-no-predef.check b/test/files/run/repl-no-imports-no-predef.check index 77655db173..b5dfbd1925 100644 --- a/test/files/run/repl-no-imports-no-predef.check +++ b/test/files/run/repl-no-imports-no-predef.check @@ -76,15 +76,9 @@ y: Int = 13 scala> scala> 2 ; 3 -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -2 ;; -^ res14: Int = 3 scala> { 2 ; 3 } -:12: warning: a pure expression does nothing in statement position; multiline expressions might require enclosing parentheses -{ 2 ; 3 } - ^ res15: Int = 3 scala> 5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Moooooo" } ; 30 ; def @@ -92,18 +86,6 @@ bippy = { 1 + 2 + 3 } ; bippy+88+11 -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Moooooo" } ; 30 ; def -^ -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Moooooo" } ; 30 ; def - ^ -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Moooooo" } ; 30 ; def - ^ -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Moooooo" } ; 30 ; def - ^ defined object Cow defined class Moo bippy: Int @@ -143,12 +125,6 @@ scala> ( (2 + 2 ) ) res24: Int = 4 scala> 5 ; ( (2 + 2 ) ) ; ((5)) -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -5 ; ( (2 + 2 ) ) ;; -^ -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -5 ; ( (2 + 2 ) ) ;; - ^ res25: Int = 5 scala> (((2 + 2)), ((2 + 2))) @@ -163,18 +139,9 @@ res28: String = 4423 scala> scala> 55 ; ((2 + 2)) ; (1, 2, 3) -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -55 ; ((2 + 2)) ;; -^ -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -55 ; ((2 + 2)) ;; - ^ res29: (Int, Int, Int) = (1,2,3) scala> 55 ; (x: scala.Int) => x + 1 ; () => ((5)) -:12: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -55 ; (x: scala.Int) => x + 1 ;; -^ res30: () => Int = scala> @@ -183,9 +150,6 @@ scala> () => 5 res31: () => Int = scala> 55 ; () => 5 -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -55 ;; -^ res32: () => Int = scala> () => { class X ; new X } diff --git a/test/files/run/repl-parens.check b/test/files/run/repl-parens.check index d6065bb1fa..5e6a07175f 100644 --- a/test/files/run/repl-parens.check +++ b/test/files/run/repl-parens.check @@ -18,12 +18,6 @@ scala> ( (2 + 2 ) ) res5: Int = 4 scala> 5 ; ( (2 + 2 ) ) ; ((5)) -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -5 ; ( (2 + 2 ) ) ;; -^ -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -5 ; ( (2 + 2 ) ) ;; - ^ res6: Int = 5 scala> (((2 + 2)), ((2 + 2))) @@ -38,18 +32,9 @@ res9: String = 4423 scala> scala> 55 ; ((2 + 2)) ; (1, 2, 3) -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -55 ; ((2 + 2)) ;; -^ -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -55 ; ((2 + 2)) ;; - ^ res10: (Int, Int, Int) = (1,2,3) scala> 55 ; (x: Int) => x + 1 ; () => ((5)) -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -55 ; (x: Int) => x + 1 ;; -^ res11: () => Int = scala> @@ -58,9 +43,6 @@ scala> () => 5 res12: () => Int = scala> 55 ; () => 5 -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -55 ;; -^ res13: () => Int = scala> () => { class X ; new X } diff --git a/test/files/run/repl-power.check b/test/files/run/repl-power.check index a1b8060ff2..84fd238da1 100644 --- a/test/files/run/repl-power.check +++ b/test/files/run/repl-power.check @@ -7,11 +7,9 @@ Try :help or completions for vals._ and power._ scala> // guarding against "error: reference to global is ambiguous" scala> global.emptyValDef // "it is imported twice in the same scope by ..." -warning: one deprecation (since 2.11.0); for details, enable `:setting -deprecation' or `:replay -deprecation' res0: $r.global.noSelfType.type = private val _ = _ scala> val tp = ArrayClass[scala.util.Random] // magic with tags -warning: one feature warning; for details, enable `:setting -feature' or `:replay -feature' tp: $r.global.Type = Array[scala.util.Random] scala> tp.memberType(Array_apply) // evidence diff --git a/test/files/run/t4172.check b/test/files/run/t4172.check index 3eca62ccdf..9b71d3ab11 100644 --- a/test/files/run/t4172.check +++ b/test/files/run/t4172.check @@ -1,6 +1,5 @@ scala> val c = { class C { override def toString = "C" }; ((new C, new C { def f = 2 })) } -warning: one feature warning; for details, enable `:setting -feature' or `:replay -feature' c: (C, C{def f: Int}) forSome { type C <: AnyRef } = (C,C) scala> :quit diff --git a/test/files/run/t4542.check b/test/files/run/t4542.check index cfc551de9f..94d948205d 100644 --- a/test/files/run/t4542.check +++ b/test/files/run/t4542.check @@ -5,9 +5,6 @@ scala> @deprecated("foooo", "ReplTest version 1.0-FINAL") class Foo() { defined class Foo scala> val f = new Foo -:12: warning: class Foo is deprecated (since ReplTest version 1.0-FINAL): foooo -val f = new Foo - ^ f: Foo = Bippy scala> :quit diff --git a/test/files/run/t4594-repl-settings.check b/test/files/run/t4594-repl-settings.check index 2dc4992528..f2b4cd5d68 100644 --- a/test/files/run/t4594-repl-settings.check +++ b/test/files/run/t4594-repl-settings.check @@ -3,15 +3,11 @@ scala> @deprecated(message="Please don't do that.", since="Time began.") def dep depp: String scala> def a = depp -warning: one deprecation (since Time began.); for details, enable `:setting -deprecation' or `:replay -deprecation' a: String scala> :settings -deprecation scala> def b = depp -:12: warning: method depp is deprecated (since Time began.): Please don't do that. -def b = depp - ^ b: String scala> :quit diff --git a/test/files/run/t4710.check b/test/files/run/t4710.check index fbf50014c5..2142043d74 100644 --- a/test/files/run/t4710.check +++ b/test/files/run/t4710.check @@ -1,6 +1,5 @@ scala> def method : String = { implicit def f(s: Symbol) = "" ; 'symbol } -warning: one feature warning; for details, enable `:setting -feature' or `:replay -feature' method: String scala> :quit diff --git a/test/files/run/t6329_repl.check b/test/files/run/t6329_repl.check index b30f075b48..ec3d17dc13 100644 --- a/test/files/run/t6329_repl.check +++ b/test/files/run/t6329_repl.check @@ -3,28 +3,24 @@ scala> import scala.reflect.classTag import scala.reflect.classTag scala> classManifest[scala.List[_]] -warning: one deprecation (since 2.10.0); for details, enable `:setting -deprecation' or `:replay -deprecation' res0: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List[] scala> classTag[scala.List[_]] res1: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List scala> classManifest[scala.collection.immutable.List[_]] -warning: one deprecation (since 2.10.0); for details, enable `:setting -deprecation' or `:replay -deprecation' res2: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List[] scala> classTag[scala.collection.immutable.List[_]] res3: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List scala> classManifest[Predef.Set[_]] -warning: one deprecation (since 2.10.0); for details, enable `:setting -deprecation' or `:replay -deprecation' res4: scala.reflect.ClassTag[scala.collection.immutable.Set[_]] = scala.collection.immutable.Set[] scala> classTag[Predef.Set[_]] res5: scala.reflect.ClassTag[scala.collection.immutable.Set[_]] = scala.collection.immutable.Set scala> classManifest[scala.collection.immutable.Set[_]] -warning: one deprecation (since 2.10.0); for details, enable `:setting -deprecation' or `:replay -deprecation' res6: scala.reflect.ClassTag[scala.collection.immutable.Set[_]] = scala.collection.immutable.Set[] scala> classTag[scala.collection.immutable.Set[_]] diff --git a/test/files/run/t6329_repl_bug.check b/test/files/run/t6329_repl_bug.check index 9ec14b7521..494d5cf894 100644 --- a/test/files/run/t6329_repl_bug.check +++ b/test/files/run/t6329_repl_bug.check @@ -6,7 +6,6 @@ scala> import scala.reflect.runtime._ import scala.reflect.runtime._ scala> classManifest[List[_]] -warning: one deprecation (since 2.10.0); for details, enable `:setting -deprecation' or `:replay -deprecation' res0: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List[] scala> scala.reflect.classTag[List[_]] diff --git a/test/files/run/t7319.check b/test/files/run/t7319.check index d4546e2fc4..d2eeacb71f 100644 --- a/test/files/run/t7319.check +++ b/test/files/run/t7319.check @@ -3,15 +3,12 @@ scala> class M[A] defined class M scala> implicit def ma0[A](a: A): M[A] = null -warning: one feature warning; for details, enable `:setting -feature' or `:replay -feature' ma0: [A](a: A)M[A] scala> implicit def ma1[A](a: A): M[A] = null -warning: one feature warning; for details, enable `:setting -feature' or `:replay -feature' ma1: [A](a: A)M[A] scala> def convert[F[X <: F[X]]](builder: F[_ <: F[_]]) = 0 -warning: one feature warning; for details, enable `:setting -feature' or `:replay -feature' convert: [F[X <: F[X]]](builder: F[_ <: F[_]])Int scala> convert(Some[Int](0)) diff --git a/test/files/run/t7747-repl.check b/test/files/run/t7747-repl.check index 8e2f0e23c1..40f970f708 100644 --- a/test/files/run/t7747-repl.check +++ b/test/files/run/t7747-repl.check @@ -15,33 +15,15 @@ scala> val z = x * y z: Int = 156 scala> 2 ; 3 -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -2 ;; -^ res0: Int = 3 scala> { 2 ; 3 } -:12: warning: a pure expression does nothing in statement position; multiline expressions might require enclosing parentheses -{ 2 ; 3 } - ^ res1: Int = 3 scala> 5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Moooooo" } ; 30 ; def bippy = { 1 + 2 + 3 } ; bippy+88+11 -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Moooooo" } ; 30 ; def bippy = { -^ -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Moooooo" } ; 30 ; def bippy = { - ^ -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Moooooo" } ; 30 ; def bippy = { - ^ -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Moooooo" } ; 30 ; def bippy = { - ^ defined object Cow defined class Moo bippy: Int @@ -81,12 +63,6 @@ scala> ( (2 + 2 ) ) res10: Int = 4 scala> 5 ; ( (2 + 2 ) ) ; ((5)) -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -5 ; ( (2 + 2 ) ) ;; -^ -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -5 ; ( (2 + 2 ) ) ;; - ^ res11: Int = 5 scala> (((2 + 2)), ((2 + 2))) @@ -101,18 +77,9 @@ res14: String = 4423 scala> scala> 55 ; ((2 + 2)) ; (1, 2, 3) -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -55 ; ((2 + 2)) ;; -^ -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -55 ; ((2 + 2)) ;; - ^ res15: (Int, Int, Int) = (1,2,3) scala> 55 ; (x: Int) => x + 1 ; () => ((5)) -:12: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -55 ; (x: Int) => x + 1 ;; -^ res16: () => Int = scala> @@ -121,9 +88,6 @@ scala> () => 5 res17: () => Int = scala> 55 ; () => 5 -:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses -55 ;; -^ res18: () => Int = scala> () => { class X ; new X } diff --git a/test/files/run/xMigration.check b/test/files/run/xMigration.check index 0ddc8996cf..3b36a34b43 100644 --- a/test/files/run/xMigration.check +++ b/test/files/run/xMigration.check @@ -10,10 +10,6 @@ res1: Iterable[String] = MapLike.DefaultValuesIterable(eis) scala> :setting -Xmigration:any scala> Map(1 -> "eis").values // warn -:12: warning: method values in trait MapLike has changed semantics in version 2.8.0: -`values` returns `Iterable[V]` rather than `Iterator[V]`. -Map(1 -> "eis").values // warn - ^ res2: Iterable[String] = MapLike.DefaultValuesIterable(eis) scala> :setting -Xmigration:2.8 @@ -24,10 +20,6 @@ res3: Iterable[String] = MapLike.DefaultValuesIterable(eis) scala> :setting -Xmigration:2.7 scala> Map(1 -> "eis").values // warn -:12: warning: method values in trait MapLike has changed semantics in version 2.8.0: -`values` returns `Iterable[V]` rather than `Iterator[V]`. -Map(1 -> "eis").values // warn - ^ res4: Iterable[String] = MapLike.DefaultValuesIterable(eis) scala> :setting -Xmigration:2.11 @@ -38,10 +30,6 @@ res5: Iterable[String] = MapLike.DefaultValuesIterable(eis) scala> :setting -Xmigration // same as :any scala> Map(1 -> "eis").values // warn -:12: warning: method values in trait MapLike has changed semantics in version 2.8.0: -`values` returns `Iterable[V]` rather than `Iterator[V]`. -Map(1 -> "eis").values // warn - ^ res6: Iterable[String] = MapLike.DefaultValuesIterable(eis) scala> :quit diff --git a/test/scaladoc/run/t5527.scala b/test/scaladoc/run/t5527.scala index d572370867..0f567557dd 100644 --- a/test/scaladoc/run/t5527.scala +++ b/test/scaladoc/run/t5527.scala @@ -1,13 +1,12 @@ -import scala.tools.partest._ -import java.io._ -import scala.tools.nsc._ import scala.tools.cmd.CommandLineParser -import scala.tools.nsc.doc.{Settings, DocFactory} +import scala.tools.nsc, nsc.doc +import scala.tools.nsc.doc.DocFactory import scala.tools.nsc.reporters.ConsoleReporter +import scala.tools.partest.DirectTest object Test extends DirectTest { - override def extraSettings: String = "-usejavacp -Xprint:parser -Yrangepos -Ystop-after:parser -d " + testOutput.path + override def extraSettings: String = "-usejavacp -Xprint:parser -Yrangepos -Ystop-after:parser" override def code = """ // scala/bug#5527 @@ -143,11 +142,13 @@ object Test extends DirectTest { compile() System.setErr(prevErr) } - - override def newCompiler(args: String*): Global = { - // we want the Scaladoc compiler here, because it keeps DocDef nodes in the tree - val settings = new Settings(_ => ()) - val command = new ScalaDoc.Command((CommandLineParser tokenize extraSettings) ++ args.toList, settings) - new DocFactory(new ConsoleReporter(settings), settings).compiler + // doc.Settings + override def newSettings(args: List[String]) = { + val s = new doc.Settings(_ => ()) + s.processArguments(args, true) + s } + // ScaladocGlobal yielded by DocFactory#compiler, requires doc.Settings + // we want the Scaladoc compiler here, because it keeps DocDef nodes in the tree + override def newCompiler(settings: nsc.Settings) = new DocFactory(reporter(settings), settings.asInstanceOf[doc.Settings]).compiler }