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

Improve attribute handling in opaqueGenericParameters rule #1713

Conversation

calda
Copy link
Collaborator

@calda calda commented Jun 2, 2024

This PR improves attribute handling in the opaqueGenericParameters rule.

To fix #1684, 383fd48 made it so the opaqueGenericParameters was disabled for all functions with attributes. However, in most cases attributes don't cause any issues. For example:

@MyResultBuilder
func foo<T: Foo, U: Bar>(foo: T, bar: U) -> MyResult {
    foo
    bar
}

@MyFunctionBodyMacro(withArgument: true)
func foo<T: Foo, U: Bar>(foo: T, bar: U) {
    print(foo, bar)
}

This PR tweaks the existing fix to check the tokens of the attributes, and whether or not they reference any of the generic arguments. #1684 remains fixed, and the above examples are now updated as expected:

@MyResultBuilder
func foo(foo: some Foo, bar: some Bar) -> MyResult {
    foo
    bar
}

@MyFunctionBodyMacro(withArgument: true)
func foo(foo: some Foo, bar: some Bar) {
    print(foo, bar)
}

Copy link

codecov bot commented Jun 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.14%. Comparing base (f487996) to head (91bf6e3).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1713   +/-   ##
========================================
  Coverage    95.13%   95.14%           
========================================
  Files           20       20           
  Lines        23124    23130    +6     
========================================
+ Hits         21998    22006    +8     
+ Misses        1126     1124    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nicklockwood nicklockwood merged commit 000a306 into nicklockwood:develop Jun 3, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants