Skip to content

Commit ce8fe60

Browse files
committed
[Parse] Drop Swift3 support for misc diagnostics
Several diagnostics were warning in Swift3, but errors in Swift4+ Essentially a revert of swiftlang#10908
1 parent 9f055be commit ce8fe60

File tree

8 files changed

+20
-87
lines changed

8 files changed

+20
-87
lines changed

include/swift/AST/DiagnosticsParse.def

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,6 @@ ERROR(static_func_decl_global_scope,none,
339339
(StaticSpellingKind))
340340
ERROR(func_decl_expected_arrow,none,
341341
"expected '->' after function parameter tuple", ())
342-
WARNING(swift3_operator_static_in_protocol,none,
343-
"operator '%0' declared in protocol must be 'static'",
344-
(StringRef))
345342
ERROR(operator_static_in_protocol,none,
346343
"operator '%0' declared in protocol must be 'static'",
347344
(StringRef))
@@ -434,13 +431,8 @@ ERROR(expected_operator_name_after_operator,PointsToFirstBadToken,
434431
ERROR(identifier_when_expecting_operator,PointsToFirstBadToken,
435432
"%0 is considered to be an identifier, not an operator", (Identifier))
436433

437-
WARNING(swift3_deprecated_operator_body,PointsToFirstBadToken,
438-
"operator should no longer be declared with body", ())
439434
ERROR(deprecated_operator_body,PointsToFirstBadToken,
440435
"operator should no longer be declared with body", ())
441-
WARNING(swift3_deprecated_operator_body_use_group,PointsToFirstBadToken,
442-
"operator should no longer be declared with body; "
443-
"use a precedence group instead", ())
444436
ERROR(deprecated_operator_body_use_group,PointsToFirstBadToken,
445437
"operator should no longer be declared with body; "
446438
"use a precedence group instead", ())
@@ -775,16 +767,10 @@ ERROR(tuple_type_multiple_labels,none,
775767
ERROR(expected_rangle_protocol,PointsToFirstBadToken,
776768
"expected '>' to complete protocol-constrained type", ())
777769

778-
WARNING(swift3_deprecated_protocol_composition,none,
779-
"'protocol<...>' composition syntax is deprecated; join the protocols using '&'", ())
780770
ERROR(deprecated_protocol_composition,none,
781771
"'protocol<...>' composition syntax has been removed; join the protocols using '&'", ())
782-
WARNING(swift3_deprecated_protocol_composition_single,none,
783-
"'protocol<...>' composition syntax is deprecated and not needed here", ())
784772
ERROR(deprecated_protocol_composition_single,none,
785-
"'protocol<...>' composition syntax has been removed and is not needed here", ())
786-
WARNING(swift3_deprecated_any_composition,none,
787-
"'protocol<>' syntax is deprecated; use 'Any' instead", ())
773+
"'protocol<...>' composition syntax has been removed and is not needed here", ())
788774
ERROR(deprecated_any_composition,none,
789775
"'protocol<>' syntax has been removed; use 'Any' instead", ())
790776

@@ -891,8 +877,6 @@ ERROR(parameter_curry_syntax_removed,none,
891877
ERROR(initializer_as_typed_pattern,none,
892878
"unexpected initializer in pattern; did you mean to use '='?", ())
893879

894-
WARNING(swift3_unlabeled_parameter_following_variadic_parameter,none,
895-
"a parameter following a variadic parameter requires a label", ())
896880
ERROR(unlabeled_parameter_following_variadic_parameter,none,
897881
"a parameter following a variadic parameter requires a label", ())
898882

@@ -1348,15 +1332,9 @@ ERROR(attr_noescape_conflicts_escaping_autoclosure,none,
13481332
ERROR(attr_noescape_implied_by_autoclosure,none,
13491333
"@noescape is implied by @autoclosure and should not be "
13501334
"redundantly specified", ())
1351-
WARNING(swift3_attr_autoclosure_escaping_deprecated,none,
1352-
"@autoclosure(escaping) is deprecated; use @autoclosure @escaping instead",
1353-
())
13541335
ERROR(attr_autoclosure_escaping_deprecated,none,
13551336
"@autoclosure(escaping) has been removed; use @autoclosure @escaping instead",
13561337
())
1357-
WARNING(swift3_attr_noescape_deprecated,none,
1358-
"@noescape is the default and is deprecated",
1359-
())
13601338
ERROR(attr_noescape_deprecated,none,
13611339
"@noescape is the default and has been removed",
13621340
())

lib/Parse/ParseDecl.cpp

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,9 +1823,7 @@ bool Parser::parseTypeAttribute(TypeAttributes &Attributes, bool justChecking) {
18231823
if (Attributes.has(TAK_noescape)) {
18241824
diagnose(Loc, diag::attr_noescape_conflicts_escaping_autoclosure);
18251825
} else {
1826-
diagnose(Loc, Context.isSwiftVersion3()
1827-
? diag::swift3_attr_autoclosure_escaping_deprecated
1828-
: diag::attr_autoclosure_escaping_deprecated)
1826+
diagnose(Loc, diag::attr_autoclosure_escaping_deprecated)
18291827
.fixItReplace(autoclosureEscapingParenRange, " @escaping ");
18301828
}
18311829
Attributes.setAttr(TAK_escaping, Loc);
@@ -1850,9 +1848,7 @@ bool Parser::parseTypeAttribute(TypeAttributes &Attributes, bool justChecking) {
18501848
// In SIL, the polarity of @escaping is reversed.
18511849
// @escaping is the default and @noescape is explicit.
18521850
if (!isInSILMode()) {
1853-
diagnose(Loc, Context.isSwiftVersion3()
1854-
? diag::swift3_attr_noescape_deprecated
1855-
: diag::attr_noescape_deprecated)
1851+
diagnose(Loc, diag::attr_noescape_deprecated)
18561852
.fixItRemove({Attributes.AtLoc, Loc});
18571853
}
18581854
break;
@@ -5188,10 +5184,7 @@ Parser::parseDeclFunc(SourceLoc StaticLoc, StaticSpellingKind StaticSpelling,
51885184
if (Flags & PD_InProtocol) {
51895185
switch (StaticSpelling) {
51905186
case StaticSpellingKind::None: {
5191-
auto Message = Context.isSwiftVersion3()
5192-
? diag::swift3_operator_static_in_protocol
5193-
: diag::operator_static_in_protocol;
5194-
diagnose(NameLoc, Message, SimpleName.str())
5187+
diagnose(NameLoc, diag::operator_static_in_protocol, SimpleName.str())
51955188
.fixItInsert(FuncLoc, "static ");
51965189
StaticSpelling = StaticSpellingKind::KeywordStatic;
51975190
break;
@@ -6424,15 +6417,9 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
64246417
SourceLoc lBraceLoc;
64256418
if (consumeIf(tok::l_brace, lBraceLoc)) {
64266419
if (isInfix && !Tok.is(tok::r_brace)) {
6427-
auto message = Context.isSwiftVersion3()
6428-
? diag::swift3_deprecated_operator_body_use_group
6429-
: diag::deprecated_operator_body_use_group;
6430-
diagnose(lBraceLoc, message);
6420+
diagnose(lBraceLoc, diag::deprecated_operator_body_use_group);
64316421
} else {
6432-
auto message = Context.isSwiftVersion3()
6433-
? diag::swift3_deprecated_operator_body
6434-
: diag::deprecated_operator_body;
6435-
auto Diag = diagnose(lBraceLoc, message);
6422+
auto Diag = diagnose(lBraceLoc, diag::deprecated_operator_body);
64366423
if (Tok.is(tok::r_brace)) {
64376424
SourceLoc lastGoodLoc = precedenceGroupNameLoc;
64386425
if (lastGoodLoc.isInvalid())

lib/Parse/ParsePattern.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -547,11 +547,8 @@ mapParsedParameters(Parser &parser,
547547
// Warn when an unlabeled parameter follows a variadic parameter
548548
if (ellipsisLoc.isValid() && elements.back()->isVariadic() &&
549549
param.FirstName.empty()) {
550-
auto message =
551-
parser.Context.isSwiftVersion3()
552-
? diag::swift3_unlabeled_parameter_following_variadic_parameter
553-
: diag::unlabeled_parameter_following_variadic_parameter;
554-
parser.diagnose(param.FirstNameLoc, message);
550+
parser.diagnose(param.FirstNameLoc,
551+
diag::unlabeled_parameter_following_variadic_parameter);
555552
}
556553

557554
// If this parameter had an ellipsis, check whether it's the last parameter.

lib/Parse/ParseType.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -828,16 +828,13 @@ ParserResult<TypeRepr> Parser::parseOldStyleProtocolComposition() {
828828
replacement += TrailingContent;
829829
}
830830

831-
auto isThree = Context.isSwiftVersion3();
832-
#define THREEIFY(MESSAGE) (isThree ? diag::swift3_##MESSAGE : diag::MESSAGE)
833831
// Replace 'protocol<T1, T2>' with 'T1 & T2'
834832
diagnose(ProtocolLoc,
835-
IsEmpty ? THREEIFY(deprecated_any_composition) :
836-
Protocols.size() > 1 ? THREEIFY(deprecated_protocol_composition) :
837-
THREEIFY(deprecated_protocol_composition_single))
833+
IsEmpty ? diag::deprecated_any_composition :
834+
Protocols.size() > 1 ? diag::deprecated_protocol_composition :
835+
diag::deprecated_protocol_composition_single)
838836
.highlight(composition->getSourceRange())
839837
.fixItReplace(composition->getSourceRange(), replacement);
840-
#undef THREEIFY
841838
}
842839

843840
return makeParserResult(Status, composition);

test/Interpreter/bool_as_generic.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// RUN: %target-run-simple-swift-swift3 | %FileCheck %s
1+
// RUN: %target-run-simple-swift | %FileCheck %s
22
// REQUIRES: executable_test
33
// <rdar://problem/13986638> Missing Bool metadata when Bool is used as a generic
44
// parameter or existential value
55

6-
prefix operator !! {}
7-
infix operator &&& {}
6+
prefix operator !!
7+
infix operator &&&
88

99
protocol BooleanProtocol {
1010
var boolValue: Bool { get }

test/Interpreter/tuples.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// RUN: %target-run-simple-swift-swift3 | %FileCheck %s
1+
// RUN: %target-run-simple-swift | %FileCheck %s
22
// REQUIRES: executable_test
33

44
typealias Interval = (lo: Int, hi: Int)
55

6-
infix operator <+> {}
7-
infix operator <-> {}
8-
infix operator <+>= {}
6+
infix operator <+>
7+
infix operator <->
8+
infix operator <+>=
99

1010
func <+>(a: Interval, b: Interval) -> Interval {
1111
return (a.lo + b.lo, a.hi + b.hi)

test/Parse/swift3_warnings_swift4_errors_version_3.swift

Lines changed: 0 additions & 26 deletions
This file was deleted.

test/Prototypes/GenericDispatch.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// prototype to which we can refer when building the standard library.
1616
//
1717
//===----------------------------------------------------------------------===//
18-
// RUN: %target-run-simple-swift-swift3 | %FileCheck %s
18+
// RUN: %target-run-simple-swift | %FileCheck %s
1919
// REQUIRES: executable_test
2020

2121
// CHECK: testing...
@@ -34,7 +34,7 @@ protocol F {
3434
// refinement of F having a non-default distance implementation need
3535
// to know about it. These refinements are expected to be rare
3636
// (which is why defaulted requirements are a win)
37-
func ~> (_: Self, _: (_Distance, (Self))) -> Int
37+
static func ~> (_: Self, _: (_Distance, (Self))) -> Int
3838
}
3939

4040
// Operation tag for distance

0 commit comments

Comments
 (0)