Skip to content

SwiftFixIt: Skip duplicate insertion fix-its #8892

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

Merged
merged 2 commits into from
Jul 9, 2025
Merged

SwiftFixIt: Skip duplicate insertion fix-its #8892

merged 2 commits into from
Jul 9, 2025

Conversation

AnthonyLatsis
Copy link
Contributor

@AnthonyLatsis AnthonyLatsis commented Jul 3, 2025

Motivation:

There are various scenarios — most notably involving protocol compositions — where multiple different sites are diagnosed with the same insertion fix-it. For example, compiling the following code with -enable-upcoming-feature InferIsolatedConformances:migrate generates 2 warnings with equal fix-its for prepending nonisolated to the composition:

protocol P {}
protocol Q {}

@MainActor struct S: P & Q {}

Applying both fix-its will produce invalid code: @MainActor struct S: nonisolated nonisolated P & Q {}.

Modifications:

Use new SwiftIDEUtils.apply parameter (swiftlang/swift-syntax#3121).

Result:

Duplicate insertion fix-its are skipped.

@AnthonyLatsis
Copy link
Contributor Author

swiftlang/swift-syntax#3121

@swift-ci please test macOS

1 similar comment
@AnthonyLatsis
Copy link
Contributor Author

swiftlang/swift-syntax#3121

@swift-ci please test macOS

@AnthonyLatsis
Copy link
Contributor Author

@swift-ci please test

@AnthonyLatsis AnthonyLatsis enabled auto-merge (rebase) July 8, 2025 11:33
There are various scenarios — most notably involving protocol
compositions — where multiple different sites are diagnosed with the
same insertion fix-it. For example, compiling the following code with
`-enable-upcoming-feature InferIsolatedConformances:migrate` generates 2
warnings with equal fix-its for prepending `nonisolated` to the
composition:

```swift
protocol P {}
protocol Q {}

@mainactor struct S: P & Q {}
```

Applying both fix-its will produce invalid code:
`@MainActor struct S: nonisolated nonisolated P & Q {}`.
@AnthonyLatsis
Copy link
Contributor Author

@swift-ci please test

@AnthonyLatsis
Copy link
Contributor Author

@swift-ci please test

@AnthonyLatsis
Copy link
Contributor Author

@swift-ci please test Windows

@AnthonyLatsis AnthonyLatsis merged commit e289541 into main Jul 9, 2025
6 checks passed
@AnthonyLatsis AnthonyLatsis deleted the jepa branch July 9, 2025 14:57
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.

3 participants