summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-02-05 00:46:58 +0100
committerHubert Plociniczak <hubert.plociniczak@gmail.com>2013-02-08 17:51:43 +0100
commite0068b908517768e900a3945e483e9c379d728d8 (patch)
tree680ac5fb751dc183c70a2db6f73670a041dd1c95
parent8d25d05e9bf848d763e7b657d9c7e96ea5cb8daf (diff)
downloadscala-e0068b908517768e900a3945e483e9c379d728d8.tar.gz
scala-e0068b908517768e900a3945e483e9c379d728d8.tar.bz2
scala-e0068b908517768e900a3945e483e9c379d728d8.zip
SI-5675 Discard duplicate feature warnings at a position
When -feature has not been enabled, we were double counting identical feature warnings that were emitted at the same position. Normal error reporting only reports the first time a warning appears at a position; feature warning counter incrementing should behave the same way. @hubertp: Fixed .check files that were broken in the original commit.
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala6
-rw-r--r--test/files/buildmanager/t2650_1/t2650_1.check2
-rw-r--r--test/files/buildmanager/t2657/t2657.check2
-rw-r--r--test/files/jvm/interpreter.check4
-rw-r--r--test/files/neg/t3234.check2
-rw-r--r--test/files/neg/t5675.check2
-rw-r--r--test/files/neg/t5675.flags1
-rw-r--r--test/files/neg/t5675.scala7
-rw-r--r--test/files/run/constrained-types.check8
-rw-r--r--test/files/run/reflection-magicsymbols-repl.check2
-rw-r--r--test/files/run/t4172.check2
-rw-r--r--test/files/run/t4710.check2
-rw-r--r--test/files/run/t6028.check2
-rw-r--r--test/files/run/t6329_repl.check2
14 files changed, 27 insertions, 17 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index 757ac94dbd..116684c161 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -1193,13 +1193,13 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
/** Collects for certain classes of warnings during this run. */
class ConditionalWarning(what: String, option: Settings#BooleanSetting) {
- val warnings = new mutable.ListBuffer[(Position, String)]
+ val warnings = mutable.LinkedHashMap[Position, String]()
def warn(pos: Position, msg: String) =
if (option.value) reporter.warning(pos, msg)
- else warnings += ((pos, msg))
+ else if (!(warnings contains pos)) warnings += ((pos, msg))
def summarize() =
if (option.isDefault && warnings.nonEmpty)
- reporter.warning(NoPosition, "there were %d %s warnings; re-run with %s for details".format(warnings.size, what, option.name))
+ reporter.warning(NoPosition, "there were %d %s warning(s); re-run with %s for details".format(warnings.size, what, option.name))
}
def newUnitParser(code: String) = new syntaxAnalyzer.UnitParser(newCompilationUnit(code))
diff --git a/test/files/buildmanager/t2650_1/t2650_1.check b/test/files/buildmanager/t2650_1/t2650_1.check
index f1e4b1b8bc..2f9dd124af 100644
--- a/test/files/buildmanager/t2650_1/t2650_1.check
+++ b/test/files/buildmanager/t2650_1/t2650_1.check
@@ -1,6 +1,6 @@
builder > A.scala B.scala
compiling Set(A.scala, B.scala)
-warning: there were 1 feature warnings; re-run with -feature for details
+warning: there were 1 feature warning(s); re-run with -feature for details
Changes: Map()
builder > A.scala
compiling Set(A.scala)
diff --git a/test/files/buildmanager/t2657/t2657.check b/test/files/buildmanager/t2657/t2657.check
index 0d6709e58b..7bff078f56 100644
--- a/test/files/buildmanager/t2657/t2657.check
+++ b/test/files/buildmanager/t2657/t2657.check
@@ -1,6 +1,6 @@
builder > A.scala B.scala
compiling Set(A.scala, B.scala)
-warning: there were 1 feature warnings; re-run with -feature for details
+warning: there were 1 feature warning(s); re-run with -feature for details
Changes: Map()
builder > A.scala
compiling Set(A.scala)
diff --git a/test/files/jvm/interpreter.check b/test/files/jvm/interpreter.check
index 6145b6c4d2..96b57c7742 100644
--- a/test/files/jvm/interpreter.check
+++ b/test/files/jvm/interpreter.check
@@ -97,7 +97,7 @@ scala> case class Bar(n: Int)
defined class Bar
scala> implicit def foo2bar(foo: Foo) = Bar(foo.n)
-warning: there were 1 feature warnings; re-run with -feature for details
+warning: there were 1 feature warning(s); re-run with -feature for details
foo2bar: (foo: Foo)Bar
scala> val bar: Bar = Foo(3)
@@ -271,7 +271,7 @@ scala> xs map (x => x)
res6: Array[_] = Array(1, 2)
scala> xs map (x => (x, x))
-warning: there were 1 feature warnings; re-run with -feature for details
+warning: there were 1 feature warning(s); re-run with -feature for details
res7: Array[(_$1, _$1)] forSome { type _$1 } = Array((1,1), (2,2))
scala>
diff --git a/test/files/neg/t3234.check b/test/files/neg/t3234.check
index 477b021e5e..4339950ecb 100644
--- a/test/files/neg/t3234.check
+++ b/test/files/neg/t3234.check
@@ -1,2 +1,2 @@
-error: there were 1 inliner warnings; re-run with -Yinline-warnings for details
+error: there were 1 inliner warning(s); re-run with -Yinline-warnings for details
one error found
diff --git a/test/files/neg/t5675.check b/test/files/neg/t5675.check
new file mode 100644
index 0000000000..da608a2b78
--- /dev/null
+++ b/test/files/neg/t5675.check
@@ -0,0 +1,2 @@
+error: there were 1 feature warning(s); re-run with -feature for details
+one error found
diff --git a/test/files/neg/t5675.flags b/test/files/neg/t5675.flags
new file mode 100644
index 0000000000..e8fb65d50c
--- /dev/null
+++ b/test/files/neg/t5675.flags
@@ -0,0 +1 @@
+-Xfatal-warnings \ No newline at end of file
diff --git a/test/files/neg/t5675.scala b/test/files/neg/t5675.scala
new file mode 100644
index 0000000000..238ed0fcae
--- /dev/null
+++ b/test/files/neg/t5675.scala
@@ -0,0 +1,7 @@
+class PostFix {
+ val list = List(1, 2, 3)
+ def main(args: Array[String]) {
+ val a = list filter (2 !=)
+ val b = list filter (2 != _)
+ }
+}
diff --git a/test/files/run/constrained-types.check b/test/files/run/constrained-types.check
index da97a378e6..85c4f41872 100644
--- a/test/files/run/constrained-types.check
+++ b/test/files/run/constrained-types.check
@@ -75,11 +75,11 @@ scala> var four = "four"
four: String = four
scala> val four2 = m(four) // should have an existential bound
-warning: there were 1 feature warnings; re-run with -feature for details
+warning: there were 1 feature warning(s); re-run with -feature for details
four2: String @Annot(x) forSome { val x: String } = four
scala> val four3 = four2 // should have the same type as four2
-warning: there were 1 feature warnings; re-run with -feature for details
+warning: there were 1 feature warning(s); re-run with -feature for details
four3: String @Annot(x) forSome { val x: String } = four
scala> val stuff = m("stuff") // should not crash
@@ -102,7 +102,7 @@ scala> def m = {
val y : String @Annot(x) = x
y
} // x should not escape the local scope with a narrow type
-warning: there were 1 feature warnings; re-run with -feature for details
+warning: there were 1 feature warning(s); re-run with -feature for details
m: String @Annot(x) forSome { val x: String }
scala>
@@ -116,7 +116,7 @@ scala> def n(y: String) = {
}
m("stuff".stripMargin)
} // x should be existentially bound
-warning: there were 1 feature warnings; re-run with -feature for details
+warning: there were 1 feature warning(s); re-run with -feature for details
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 d3cd26f25f..2535e3f43d 100644
--- a/test/files/run/reflection-magicsymbols-repl.check
+++ b/test/files/run/reflection-magicsymbols-repl.check
@@ -23,7 +23,7 @@ scala> def test(n: Int): Unit = {
val x = sig.asInstanceOf[MethodType].params.head
println(x.typeSignature)
}
-warning: there were 1 feature warnings; re-run with -feature for details
+warning: there were 1 feature warning(s); re-run with -feature for details
test: (n: Int)Unit
scala> for (i <- 1 to 8) test(i)
diff --git a/test/files/run/t4172.check b/test/files/run/t4172.check
index 94cdff4870..b48c9ca056 100644
--- a/test/files/run/t4172.check
+++ b/test/files/run/t4172.check
@@ -4,7 +4,7 @@ Type :help for more information.
scala>
scala> val c = { class C { override def toString = "C" }; ((new C, new C { def f = 2 })) }
-warning: there were 1 feature warnings; re-run with -feature for details
+warning: there were 1 feature warning(s); re-run with -feature for details
c: (C, C{def f: Int}) forSome { type C <: AnyRef } = (C,C)
scala>
diff --git a/test/files/run/t4710.check b/test/files/run/t4710.check
index 7c2b10b098..f2335d1bdd 100644
--- a/test/files/run/t4710.check
+++ b/test/files/run/t4710.check
@@ -2,7 +2,7 @@ Type in expressions to have them evaluated.
Type :help for more information.
scala> def method : String = { implicit def f(s: Symbol) = "" ; 'symbol }
-warning: there were 1 feature warnings; re-run with -feature for details
+warning: there were 1 feature warning(s); re-run with -feature for details
method: String
scala>
diff --git a/test/files/run/t6028.check b/test/files/run/t6028.check
index 79deaacf3a..94013efd36 100644
--- a/test/files/run/t6028.check
+++ b/test/files/run/t6028.check
@@ -81,4 +81,4 @@ package <empty> {
}
}
-warning: there were 1 feature warnings; re-run with -feature for details
+warning: there were 1 feature warning(s); re-run with -feature for details
diff --git a/test/files/run/t6329_repl.check b/test/files/run/t6329_repl.check
index 8663184bde..693263a5c2 100644
--- a/test/files/run/t6329_repl.check
+++ b/test/files/run/t6329_repl.check
@@ -4,7 +4,7 @@ Type :help for more information.
scala>
scala> classManifest[List[_]]
-warning: there were 1 deprecation warnings; re-run with -deprecation for details
+warning: there were 1 deprecation warning(s); re-run with -deprecation for details
res0: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List[Any]
scala> scala.reflect.classTag[List[_]]