Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix @nowarn to use correct semantics for & #9032

Merged
merged 1 commit into from Jun 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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