Skip to content

Commit 55e1aa2

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

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
@@ -1647,7 +1647,9 @@ bool Parser::parseTypeAttribute(TypeAttributes &Attributes, bool justChecking) {
16471647
if (Attributes.has(TAK_noescape)) {
16481648
diagnose(Loc, diag::attr_noescape_conflicts_escaping_autoclosure);
16491649
} else {
1650-
diagnose(Loc, diag::attr_autoclosure_escaping_deprecated)
1650+
diagnose(Loc, Context.isSwiftVersion3()
1651+
? diag::swift3_attr_autoclosure_escaping_deprecated
1652+
: diag::attr_autoclosure_escaping_deprecated)
16511653
.fixItReplace(autoclosureEscapingParenRange, " @escaping ");
16521654
}
16531655
Attributes.setAttr(TAK_escaping, Loc);
@@ -1669,8 +1671,10 @@ bool Parser::parseTypeAttribute(TypeAttributes &Attributes, bool justChecking) {
16691671
}
16701672

16711673
// @noescape is deprecated and no longer used
1672-
diagnose(Loc, diag::attr_noescape_deprecated)
1673-
.fixItRemove({Attributes.AtLoc,Loc});
1674+
diagnose(Loc, Context.isSwiftVersion3()
1675+
? diag::swift3_attr_noescape_deprecated
1676+
: diag::attr_noescape_deprecated)
1677+
.fixItRemove({Attributes.AtLoc, Loc});
16741678

16751679
break;
16761680
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)