-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Restrict implicit lint to view #10781
Restrict implicit lint to view #10781
Conversation
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
t match { | ||
case Apply(coercion, _) if t.isInstanceOf[ApplyImplicitView] => | ||
coercion.symbol.paramLists match { | ||
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
to
baa66b2
Compare
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. |
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!
Only warn about a block arg passed into the by-name param of an implicit method if it was an implicit view.
Fixes scala/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.