[Sema] Clarify diagnostic for type attributes only valid in inheritance clauses#88585
Open
qflen wants to merge 1 commit intoswiftlang:mainfrom
Open
[Sema] Clarify diagnostic for type attributes only valid in inheritance clauses#88585qflen wants to merge 1 commit intoswiftlang:mainfrom
qflen wants to merge 1 commit intoswiftlang:mainfrom
Conversation
…ce clauses The shared diagnostic for @unchecked, @preconcurrency, @unsafe, and @nonisolated used in an invalid type-attribute position read "only applies in inheritance clauses", which is misleading since all four have valid declaration-attribute uses elsewhere (imports, funcs, etc.). Reword to "can only be used as a type attribute in inheritance clauses" so the error scopes itself to the type-attribute form. Fixes swiftlang#88338.
Author
|
For reviewer context: #88356 (Apr 8) also addresses #88338 with a similar test-expectation update but a different wording choice: I landed on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #88338.
The shared diagnostic
typeattr_not_inheritance_clausefires for@unchecked,@preconcurrency,@unsafe, and@nonisolatedwhen used as a type attribute outside an inheritance clause. The old wording,"%0 only applies in inheritance clauses", reads as a universal claim about the attribute, but all four have valid declaration-attribute uses elsewhere (imports, funcs, etc.).Reworded to
"%0 can only be used as a type attribute in inheritance clauses"so the error scopes itself to the type-attribute form.Changes
include/swift/AST/DiagnosticsSema.def: updated diagnostic text.test/Concurrency/preconcurrency_conformances.swift: updated 4 expectations, added a regression test for the reporter's repro (let _: @preconcurrency @MainActor () -> Void = {}).test/Concurrency/concurrent_value_checking_typechecker_errors.swift: updated 2 expectations.No logic changes. The
@retroactivesibling diagnostic is unchanged since its wording is already scoped correctly.