Skip to content
This repository
Browse code

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.
  • Loading branch information...
commit e0068b908517768e900a3945e483e9c379d728d8 1 parent 8d25d05
Jason Zaugg authored February 05, 2013 hubertp committed February 08, 2013
6  src/compiler/scala/tools/nsc/Global.scala
@@ -1193,13 +1193,13 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
1193 1193
 
1194 1194
   /** Collects for certain classes of warnings during this run. */
1195 1195
   class ConditionalWarning(what: String, option: Settings#BooleanSetting) {
1196  
-    val warnings = new mutable.ListBuffer[(Position, String)]
  1196
+    val warnings = mutable.LinkedHashMap[Position, String]()
1197 1197
     def warn(pos: Position, msg: String) =
1198 1198
       if (option.value) reporter.warning(pos, msg)
1199  
-      else warnings += ((pos, msg))
  1199
+      else if (!(warnings contains pos)) warnings += ((pos, msg))
1200 1200
     def summarize() =
1201 1201
       if (option.isDefault && warnings.nonEmpty)
1202  
-        reporter.warning(NoPosition, "there were %d %s warnings; re-run with %s for details".format(warnings.size, what, option.name))
  1202
+        reporter.warning(NoPosition, "there were %d %s warning(s); re-run with %s for details".format(warnings.size, what, option.name))
1203 1203
   }
1204 1204
 
1205 1205
   def newUnitParser(code: String)      = new syntaxAnalyzer.UnitParser(newCompilationUnit(code))
2  test/files/buildmanager/t2650_1/t2650_1.check
... ...
@@ -1,6 +1,6 @@
1 1
 builder > A.scala B.scala
2 2
 compiling Set(A.scala, B.scala)
3  
-warning: there were 1 feature warnings; re-run with -feature for details
  3
+warning: there were 1 feature warning(s); re-run with -feature for details
4 4
 Changes: Map()
5 5
 builder > A.scala
6 6
 compiling Set(A.scala)
2  test/files/buildmanager/t2657/t2657.check
... ...
@@ -1,6 +1,6 @@
1 1
 builder > A.scala B.scala
2 2
 compiling Set(A.scala, B.scala)
3  
-warning: there were 1 feature warnings; re-run with -feature for details
  3
+warning: there were 1 feature warning(s); re-run with -feature for details
4 4
 Changes: Map()
5 5
 builder > A.scala
6 6
 compiling Set(A.scala)
4  test/files/jvm/interpreter.check
@@ -97,7 +97,7 @@ scala> case class Bar(n: Int)
97 97
 defined class Bar
98 98
 
99 99
 scala> implicit def foo2bar(foo: Foo) = Bar(foo.n)
100  
-warning: there were 1 feature warnings; re-run with -feature for details
  100
+warning: there were 1 feature warning(s); re-run with -feature for details
101 101
 foo2bar: (foo: Foo)Bar
102 102
 
103 103
 scala> val bar: Bar = Foo(3)
@@ -271,7 +271,7 @@ scala> xs map (x => x)
271 271
 res6: Array[_] = Array(1, 2)
272 272
 
273 273
 scala> xs map (x => (x, x))
274  
-warning: there were 1 feature warnings; re-run with -feature for details
  274
+warning: there were 1 feature warning(s); re-run with -feature for details
275 275
 res7: Array[(_$1, _$1)] forSome { type _$1 } = Array((1,1), (2,2))
276 276
 
277 277
 scala> 
2  test/files/neg/t3234.check
... ...
@@ -1,2 +1,2 @@
1  
-error: there were 1 inliner warnings; re-run with -Yinline-warnings for details
  1
+error: there were 1 inliner warning(s); re-run with -Yinline-warnings for details
2 2
 one error found
2  test/files/neg/t5675.check
... ...
@@ -0,0 +1,2 @@
  1
+error: there were 1 feature warning(s); re-run with -feature for details
  2
+one error found
1  test/files/neg/t5675.flags
... ...
@@ -0,0 +1 @@
  1
+-Xfatal-warnings
7  test/files/neg/t5675.scala
... ...
@@ -0,0 +1,7 @@
  1
+class PostFix {
  2
+  val list = List(1, 2, 3)
  3
+  def main(args: Array[String]) {
  4
+    val a = list filter (2 !=)
  5
+    val b = list filter (2 != _)
  6
+  }
  7
+}
8  test/files/run/constrained-types.check
@@ -75,11 +75,11 @@ scala> var four = "four"
75 75
 four: String = four
76 76
 
77 77
 scala> val four2 = m(four) // should have an existential bound
78  
-warning: there were 1 feature warnings; re-run with -feature for details
  78
+warning: there were 1 feature warning(s); re-run with -feature for details
79 79
 four2: String @Annot(x) forSome { val x: String } = four
80 80
 
81 81
 scala> val four3 = four2   // should have the same type as four2
82  
-warning: there were 1 feature warnings; re-run with -feature for details
  82
+warning: there were 1 feature warning(s); re-run with -feature for details
83 83
 four3: String @Annot(x) forSome { val x: String } = four
84 84
 
85 85
 scala> val stuff = m("stuff") // should not crash
@@ -102,7 +102,7 @@ scala> def m = {
102 102
   val y : String @Annot(x) = x
103 103
   y
104 104
 } // x should not escape the local scope with a narrow type
105  
-warning: there were 1 feature warnings; re-run with -feature for details
  105
+warning: there were 1 feature warning(s); re-run with -feature for details
106 106
 m: String @Annot(x) forSome { val x: String }
107 107
 
108 108
 scala> 
@@ -116,7 +116,7 @@ scala> def n(y: String) = {
116 116
   }
117 117
   m("stuff".stripMargin)
118 118
 } // x should be existentially bound
119  
-warning: there were 1 feature warnings; re-run with -feature for details
  119
+warning: there were 1 feature warning(s); re-run with -feature for details
120 120
 n: (y: String)String @Annot(x) forSome { val x: String }
121 121
 
122 122
 scala> 
2  test/files/run/reflection-magicsymbols-repl.check
@@ -23,7 +23,7 @@ scala> def test(n: Int): Unit = {
23 23
   val x = sig.asInstanceOf[MethodType].params.head
24 24
   println(x.typeSignature)
25 25
 }
26  
-warning: there were 1 feature warnings; re-run with -feature for details
  26
+warning: there were 1 feature warning(s); re-run with -feature for details
27 27
 test: (n: Int)Unit
28 28
 
29 29
 scala> for (i <- 1 to 8) test(i)
2  test/files/run/t4172.check
@@ -4,7 +4,7 @@ Type :help for more information.
4 4
 scala> 
5 5
 
6 6
 scala>     val c = { class C { override def toString = "C" }; ((new C, new C { def f = 2 })) }
7  
-warning: there were 1 feature warnings; re-run with -feature for details
  7
+warning: there were 1 feature warning(s); re-run with -feature for details
8 8
 c: (C, C{def f: Int}) forSome { type C <: AnyRef } = (C,C)
9 9
 
10 10
 scala> 
2  test/files/run/t4710.check
@@ -2,7 +2,7 @@ Type in expressions to have them evaluated.
2 2
 Type :help for more information.
3 3
 
4 4
 scala> def method : String = { implicit def f(s: Symbol) = "" ; 'symbol }
5  
-warning: there were 1 feature warnings; re-run with -feature for details
  5
+warning: there were 1 feature warning(s); re-run with -feature for details
6 6
 method: String
7 7
 
8 8
 scala> 
2  test/files/run/t6028.check
@@ -81,4 +81,4 @@ package <empty> {
81 81
   }
82 82
 }
83 83
 
84  
-warning: there were 1 feature warnings; re-run with -feature for details
  84
+warning: there were 1 feature warning(s); re-run with -feature for details
2  test/files/run/t6329_repl.check
@@ -4,7 +4,7 @@ Type :help for more information.
4 4
 scala> 
5 5
 
6 6
 scala> classManifest[List[_]]
7  
-warning: there were 1 deprecation warnings; re-run with -deprecation for details
  7
+warning: there were 1 deprecation warning(s); re-run with -deprecation for details
8 8
 res0: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List[Any]
9 9
 
10 10
 scala> scala.reflect.classTag[List[_]]

1 note on commit e0068b9

scala-jenkins
Collaborator

Job pr-rangepos-per-commit failed for e0068b9 (results):


Took 9 s.
sad kitty
to rebuild, comment "PLS REBUILD/pr-rangepos-per-commit@e0068b9"on PR #2112

Please sign in to comment.
Something went wrong with that request. Please try again.