Permalink
Browse files

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...
1 parent 8d25d05 commit e0068b908517768e900a3945e483e9c379d728d8 @retronym retronym committed with hubertp Feb 4, 2013
@@ -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))
@@ -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)
@@ -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)
@@ -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>
@@ -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
@@ -0,0 +1,2 @@
+error: there were 1 feature warning(s); re-run with -feature for details
+one error found
@@ -0,0 +1 @@
+-Xfatal-warnings
@@ -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 != _)
+ }
+}
@@ -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>
@@ -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)
@@ -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>
@@ -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>
@@ -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
@@ -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[_]]

1 comment on commit e0068b9

@scala-jenkins

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.