Skip to content

Commit ede949f

Browse files
committed
[Parse] Upgrade @noescape/@autoclosure(escaping) warnings to Swift 4 errors.
Part of rdar://problem/28961650 .
1 parent 7f38405 commit ede949f

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

include/swift/AST/DiagnosticsParse.def

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,12 +1314,18 @@ ERROR(attr_noescape_conflicts_escaping_autoclosure,none,
13141314
ERROR(attr_noescape_implied_by_autoclosure,none,
13151315
"@noescape is implied by @autoclosure and should not be "
13161316
"redundantly specified", ())
1317-
WARNING(attr_autoclosure_escaping_deprecated,none,
1317+
WARNING(swift3_attr_autoclosure_escaping_deprecated,none,
13181318
"@autoclosure(escaping) is deprecated; use @autoclosure @escaping instead",
13191319
())
1320-
WARNING(attr_noescape_deprecated,none,
1320+
ERROR(attr_autoclosure_escaping_deprecated,none,
1321+
"@autoclosure(escaping) has been removed; use @autoclosure @escaping instead",
1322+
())
1323+
WARNING(swift3_attr_noescape_deprecated,none,
13211324
"@noescape is the default and is deprecated",
13221325
())
1326+
ERROR(attr_noescape_deprecated,none,
1327+
"@noescape is the default and has been removed",
1328+
())
13231329

13241330
// convention
13251331
ERROR(convention_attribute_expected_lparen,none,

lib/Parse/ParseDecl.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,7 +1677,9 @@ bool Parser::parseTypeAttribute(TypeAttributes &Attributes, bool justChecking) {
16771677
if (Attributes.has(TAK_noescape)) {
16781678
diagnose(Loc, diag::attr_noescape_conflicts_escaping_autoclosure);
16791679
} else {
1680-
diagnose(Loc, diag::attr_autoclosure_escaping_deprecated)
1680+
diagnose(Loc, Context.isSwiftVersion3()
1681+
? diag::swift3_attr_autoclosure_escaping_deprecated
1682+
: diag::attr_autoclosure_escaping_deprecated)
16811683
.fixItReplace(autoclosureEscapingParenRange, " @escaping ");
16821684
}
16831685
Attributes.setAttr(TAK_escaping, Loc);
@@ -1699,8 +1701,10 @@ bool Parser::parseTypeAttribute(TypeAttributes &Attributes, bool justChecking) {
16991701
}
17001702

17011703
// @noescape is deprecated and no longer used
1702-
diagnose(Loc, diag::attr_noescape_deprecated)
1703-
.fixItRemove({Attributes.AtLoc,Loc});
1704+
diagnose(Loc, Context.isSwiftVersion3()
1705+
? diag::swift3_attr_noescape_deprecated
1706+
: diag::attr_noescape_deprecated)
1707+
.fixItRemove({Attributes.AtLoc, Loc});
17041708

17051709
break;
17061710
case TAK_escaping:

test/attr/attr_escaping.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ func paramDeclEscaping(@escaping fn: (Int) -> Void) {} // expected-error {{attri
66
func wrongParamType(a: @escaping Int) {} // expected-error {{@escaping attribute only applies to function types}}
77

88
func conflictingAttrs(_ fn: @noescape @escaping () -> Int) {} // expected-error {{@escaping conflicts with @noescape}}
9-
// expected-warning@-1{{@noescape is the default and is deprecated}} {{29-39=}}
9+
// expected-error@-1{{@noescape is the default and has been removed}} {{29-39=}}
1010

1111
func takesEscaping(_ fn: @escaping () -> Int) {} // ok
1212

0 commit comments

Comments
 (0)