Skip to content

Sema: Make "@retroactive attribute does not apply" a warning #71498

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/Sema/TypeCheckDeclPrimary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1689,8 +1689,10 @@ static void diagnoseRetroactiveConformances(
extTypeModule->isSameModuleLookingThroughOverlays(module);
auto incorrectTypeName = typeIsSameModule ?
extendedNominalDecl->getName() : proto->getName();
diags.diagnose(loc, diag::retroactive_attr_does_not_apply,
incorrectTypeName)
diags
.diagnose(loc, diag::retroactive_attr_does_not_apply,
incorrectTypeName)
.warnUntilSwiftVersion(6)
.fixItRemove(SourceRange(loc, loc.getAdvancedLoc(1)));
return TypeWalker::Action::Stop;
}
Expand Down
4 changes: 2 additions & 2 deletions test/Sema/extension_retroactive_conformances.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ extension Sample1: ClientProtocol {}

struct Sample7: @retroactive SampleProtocol1 {} // expected-error {{'retroactive' attribute only applies in inheritance clauses in extensions}}

extension Sample7: @retroactive ClientProtocol {} // expected-error {{'retroactive' attribute does not apply; 'Sample7' is declared in this module}}
extension Sample7: @retroactive ClientProtocol {} // expected-warning {{'retroactive' attribute does not apply; 'Sample7' is declared in this module}}

extension Int: @retroactive ClientProtocol {} // expected-error {{'retroactive' attribute does not apply; 'ClientProtocol' is declared in this module}}
extension Int: @retroactive ClientProtocol {} // expected-warning {{'retroactive' attribute does not apply; 'ClientProtocol' is declared in this module}}

func f(_ x: @retroactive Int) {} // expected-error {{'retroactive' attribute only applies in inheritance clauses in extensions}}

Expand Down
10 changes: 10 additions & 0 deletions test/Sema/extension_retroactive_conformances_swift6.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// RUN: %target-typecheck-verify-swift -swift-version 6

// REQUIRES: asserts

struct LocalStruct {}
protocol LocalProtocol {}

extension LocalStruct: @retroactive LocalProtocol {} // expected-error {{'retroactive' attribute does not apply; 'LocalStruct' is declared in this module}}

extension Int: @retroactive LocalProtocol {} // expected-error {{'retroactive' attribute does not apply; 'LocalProtocol' is declared in this module}}