- Notifications
You must be signed in to change notification settings - Fork3.1k
Fix false-positive by-name implicit warnings with-Wmacros#10781
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
lrytz left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM
| tmatch { | ||
| caseApply(coercion, _)if t.isInstanceOf[ApplyImplicitView]=> | ||
| coercion.symbol.paramListsmatch { | ||
| case (p::Nil):: _if p.isByNameParam=> refchecksWarning(t.pos,s"Block result was adapted via implicit conversion (${coercion.symbol}) taking a by-name parameter",WarningCategory.LintBynameImplicit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
| case (p::Nil):: _if p.isByNameParam=> refchecksWarning(t.pos,s"Block result was adapted via implicit conversion (${coercion.symbol}) taking a by-name parameter",WarningCategory.LintBynameImplicit) | |
| case (p::Nil):: _if p.isByNameParam=> refchecksWarning(t.pos,s"Block result was adapted via implicit conversion (${coercion.symbol}) taking a by-name parameter; statements are not evaluated eagerly",WarningCategory.LintBynameImplicit) |
or something like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Or just the opposite. This is the opposite where only the result expression is adapted. I'll upgrade both messages!
9e4b360 tobaa66b2Comparesom-snytt commentedMay 21, 2024
I pushed messages for the two cases that are less cryptic. The OP confusing case is that if a block is converted, the conversion applies only to the result expression. This matters if the method parameter is by-name. The related confusing case is that if the method is overloaded, the conversion applies to the whole block, the opposite of the first case. |
lrytz left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks!
-Wmacros
Only warn about a block arg passed into the by-name param of an implicit method if it was an implicit view.
Fixesscala/bug#12072
This implements lrytz's suggestion on the ticket.
scala/bug#12072 (comment)
Confirmed that the Shapeless 2 solutions to the guide exercises now compile cleanly.
Since Shapeless is not relying on conversions, this PR ignores the ticket title as a red herring.