Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged

Conversation

@som-snytt
Copy link
Contributor

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.

@scala-jenkinsscala-jenkins added this to the2.13.15 milestoneMay 14, 2024
@som-snyttsom-snytt marked this pull request as ready for reviewMay 14, 2024 23:34
Copy link
Member

@lrytzlrytz left a 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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
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?

som-snytt reacted with thumbs up emoji
Copy link
ContributorAuthor

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!

@som-snyttsom-snyttforce-pushed theissue/12072-lint-implicit-by-name branch from9e4b360 tobaa66b2CompareMay 21, 2024 15:45
@som-snytt
Copy link
ContributorAuthor

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.

Copy link
Member

@lrytzlrytz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks!

@lrytzlrytz merged commit896427d intoscala:2.13.xMay 22, 2024
@som-snyttsom-snytt deleted the issue/12072-lint-implicit-by-name branchMay 22, 2024 07:44
@SethTisueSethTisue added the release-notesworth highlighting in next release notes labelMay 23, 2024
@SethTisueSethTisue changed the titleRestrict implicit lint to viewFix false-positive by-name implicit warnings with-WmacrosAug 22, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@lrytzlrytzlrytz approved these changes

Assignees

No one assigned

Labels

release-notesworth highlighting in next release notes

Projects

None yet

Milestone

2.13.15

Development

Successfully merging this pull request may close these issues.

Lints should respect-Wmacros

4 participants

@som-snytt@lrytz@SethTisue@scala-jenkins

[8]ページ先頭

©2009-2025 Movatter.jp