Reputation: 6104
I have a macro that is using quasiquotes like:
accessor.tree match {
// FIXME: Get rid of the unused warning here.
case q"($source) => $rhs" => validate(rhs, hasSelect = false)
case t => c.abort(c.enclosingPosition, s"Invalid function expression ${show(t)}")
}
This gives me the following warnings:
[warn] /Users/jason/source/goodcover/core/macros/src/main/scala/webm/react/syntax/StableFieldOpsImpl.scala:36:12: pattern var qq$macro$1 in method unapply is never used: use a wildcard `_` or suppress this warning with `qq$macro$1@_`
[warn] case q"($source) => $rhs" => validate(rhs, hasSelect = false)
[warn] ^
[warn] /Users/jason/source/goodcover/core/macros/src/main/scala/webm/react/syntax/StableFieldOpsImpl.scala:36:16: pattern var source in method validateSelection is never used: use a wildcard `_` or suppress this warning with `source@_`
[warn] case q"($source) => $rhs" => validate(rhs, hasSelect = false)
[warn] ^
[warn] two warnings found
Using a wildcard doesn't work:
accessor.tree match {
// FIXME: Get rid of the unused warning here.
case q"(_) => $rhs" => validate(rhs, hasSelect = false)
case t => c.abort(c.enclosingPosition, s"Invalid function expression ${show(t)}")
}
That fails with:
[error] /Users/jason/source/goodcover/core/macros/src/main/scala/webm/react/syntax/StableFieldOpsImpl.scala:36:18: ';' expected but '=>' found.
[error] case q"(_) => $rhs" => validate(rhs, hasSelect = false)
[error] ^
[error] /Users/jason/source/goodcover/core/macros/src/main/scala/webm/react/syntax/StableFieldOpsImpl.scala:36:12: extractor macros can only expand into extractor calls
[error] case q"(_) => $rhs" => validate(rhs, hasSelect = false)
[error] ^
[error] two errors found
I don't know what suppress this warning with `source@_`
means.
If I take it literally as in:
accessor.tree match {
// FIXME: Get rid of the unused warning here.
case q"(source@_) => $rhs" => validate(rhs, hasSelect = false)
case t => c.abort(c.enclosingPosition, s"Invalid function expression ${show(t)}")
}
Then I get:
[error] /Users/jason/source/goodcover/core/macros/src/main/scala/webm/react/syntax/StableFieldOpsImpl.scala:36:21: ')' expected but '@' found.
[error] case q"(source@_) => $rhs" => validate(rhs, hasSelect = false)
[error] ^
[error] /Users/jason/source/goodcover/core/macros/src/main/scala/webm/react/syntax/StableFieldOpsImpl.scala:36:12: extractor macros can only expand into extractor calls
[error] case q"(source@_) => $rhs" => validate(rhs, hasSelect = false)
[error] ^
[error] two errors found
How do I ignore these warnings?
Upvotes: 0
Views: 291
Reputation: 419
Not sure why but adding
scalacOptions += "-Ywarn-macros:after"
makes the warning disappeared in my case.
Upvotes: 0