Skip to content

Commit b9040c7

Browse files
committed
[Diagnostics] Use warnUntilSwiftVersion for the ownership_invalid_in_protocols
diagnostic and remove ownership_invalid_in_protocols_compat_warning.
1 parent 8e282c9 commit b9040c7

File tree

4 files changed

+7
-12
lines changed

4 files changed

+7
-12
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4728,10 +4728,6 @@ ERROR(invalid_ownership_is_let,none,
47284728
ERROR(ownership_invalid_in_protocols,none,
47294729
"%0 cannot be applied to a property declaration in a protocol",
47304730
(ReferenceOwnership))
4731-
WARNING(ownership_invalid_in_protocols_compat_warning,none,
4732-
"%0 should not be applied to a property declaration "
4733-
"in a protocol and will be disallowed in future versions",
4734-
(ReferenceOwnership))
47354731

47364732
// required
47374733
ERROR(required_initializer_nonclass,none,

lib/Sema/TypeCheckAttr.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3354,10 +3354,9 @@ Type TypeChecker::checkReferenceOwnershipAttr(VarDecl *var, Type type,
33543354
if (PDC && !PDC->isObjC()) {
33553355
// Ownership does not make sense in protocols, except for "weak" on
33563356
// properties of Objective-C protocols.
3357-
auto D = var->getASTContext().isSwiftVersionAtLeast(5)
3358-
? diag::ownership_invalid_in_protocols
3359-
: diag::ownership_invalid_in_protocols_compat_warning;
3357+
auto D = diag::ownership_invalid_in_protocols;
33603358
Diags.diagnose(attr->getLocation(), D, ownershipKind)
3359+
.warnUntilSwiftVersion(5)
33613360
.fixItRemove(attr->getRange());
33623361
attr->setInvalid();
33633362
}

test/Compatibility/ownership_protocol.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
class SomeClass {}
55

66
protocol P {
7-
// expected-warning@+1 {{'weak' should not be applied to a property declaration in a protocol and will be disallowed in future versions}}
7+
// expected-warning@+1 {{'weak' cannot be applied to a property declaration in a protocol; this is an error in Swift 5}}
88
weak var foo: SomeClass? { get set }
9-
// expected-warning@+1 {{'unowned' should not be applied to a property declaration in a protocol and will be disallowed in future versions}}
9+
// expected-warning@+1 {{'unowned' cannot be applied to a property declaration in a protocol; this is an error in Swift 5}}
1010
unowned var foo2: SomeClass { get set }
11-
// expected-warning@+2 {{'weak' should not be applied to a property declaration in a protocol and will be disallowed in future versions}}
11+
// expected-warning@+2 {{'weak' cannot be applied to a property declaration in a protocol; this is an error in Swift 5}}
1212
// expected-error@+1 {{'weak' may only be applied to class and class-bound protocol types, not 'Int'}}
1313
weak var foo3: Int? { get set }
14-
// expected-warning@+2 {{'unowned' should not be applied to a property declaration in a protocol and will be disallowed in future versions}}
14+
// expected-warning@+2 {{'unowned' cannot be applied to a property declaration in a protocol; this is an error in Swift 5}}
1515
// expected-error@+1 {{'unowned' may only be applied to class and class-bound protocol types, not 'Int'}}
1616
unowned var foo4: Int { get set }
1717
}

test/decl/protocol/protocols.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ protocol ShouldntCrash {
467467

468468
// rdar://problem/18168866
469469
protocol FirstProtocol {
470-
// expected-warning@+1 {{'weak' should not be applied to a property declaration in a protocol and will be disallowed in future versions}}
470+
// expected-warning@+1 {{'weak' cannot be applied to a property declaration in a protocol; this is an error in Swift 5}}
471471
weak var delegate : SecondProtocol? { get } // expected-error{{'weak' must not be applied to non-class-bound 'SecondProtocol'; consider adding a protocol conformance that has a class bound}}
472472
}
473473

0 commit comments

Comments
 (0)