Skip to content

Commit

Permalink
Merge pull request #9032 from som-snytt/issue/12026
Browse files Browse the repository at this point in the history
All filters must match for nowarn
  • Loading branch information
SethTisue committed Jun 3, 2020
2 parents 7fff914 + 0c52dc4 commit 92809e8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/compiler/scala/tools/nsc/Reporting.scala
Expand Up @@ -612,10 +612,9 @@ object Reporting {
def used: Boolean = _used
def markUsed(): Unit = { _used = true }


def matches(message: Message): Boolean = {
val pos = message.pos
pos.isDefined && start <= pos.start && pos.end <= end && filters.exists(_.matches(message))
pos.isDefined && start <= pos.start && pos.end <= end && filters.forall(_.matches(message))
}
}
}
6 changes: 6 additions & 0 deletions test/files/neg/t12026.check
@@ -0,0 +1,6 @@
t12026.scala:11: warning: discarded non-Unit value
def f(): Unit = v()
^
error: No warnings can be incurred under -Werror.
1 warning
1 error
14 changes: 14 additions & 0 deletions test/files/neg/t12026.scala
@@ -0,0 +1,14 @@
//scalac: -Wvalue-discard -Werror

import annotation._

//the following option works and warns for f but not g
//-Wconf:cat=w-flag-value-discard&site=T.g:s

@nowarn("cat=w-flag-value-discard&site=T.g")
trait T {
def v(): Int
def f(): Unit = v()
def g(): Unit = v()
}
// was: no warning

0 comments on commit 92809e8

Please sign in to comment.