Skip to content

Commit 20105e8

Browse files
committed
[Parse] Upgrade operator_static_in_protocol to Swift 4 error.
Part of rdar://problem/28961650 .
1 parent 155e05b commit 20105e8

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

include/swift/AST/DiagnosticsParse.def

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,12 @@ ERROR(static_func_decl_global_scope,none,
320320
(StaticSpellingKind))
321321
ERROR(func_decl_expected_arrow,none,
322322
"expected '->' after function parameter tuple", ())
323-
WARNING(operator_static_in_protocol,none,
323+
WARNING(swift3_operator_static_in_protocol,none,
324324
"operator '%0' declared in protocol must be 'static'",
325325
(StringRef))
326+
ERROR(operator_static_in_protocol,none,
327+
"operator '%0' declared in protocol must be 'static'",
328+
(StringRef))
326329

327330
// Enum
328331
ERROR(expected_lbrace_enum,PointsToFirstBadToken,

lib/Parse/ParseDecl.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4722,11 +4722,15 @@ Parser::parseDeclFunc(SourceLoc StaticLoc, StaticSpellingKind StaticSpelling,
47224722
// Within a protocol, recover from a missing 'static'.
47234723
if (Flags & PD_InProtocol) {
47244724
switch (StaticSpelling) {
4725-
case StaticSpellingKind::None:
4726-
diagnose(NameLoc, diag::operator_static_in_protocol, SimpleName.str())
4727-
.fixItInsert(FuncLoc, "static ");
4725+
case StaticSpellingKind::None: {
4726+
auto Message = Context.isSwiftVersion3()
4727+
? diag::swift3_operator_static_in_protocol
4728+
: diag::operator_static_in_protocol;
4729+
diagnose(NameLoc, Message, SimpleName.str())
4730+
.fixItInsert(FuncLoc, "static ");
47284731
StaticSpelling = StaticSpellingKind::KeywordStatic;
47294732
break;
4733+
}
47304734

47314735
case StaticSpellingKind::KeywordStatic:
47324736
// Okay, this is correct.

test/SILOptimizer/devirt_static_witness_method.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Swift
66
import SwiftShims
77

88
protocol CanAdd {
9-
func +(lhs: Self, rhs: Self) -> Self
9+
static func +(lhs: Self, rhs: Self) -> Self
1010
}
1111

1212
extension Int64 : CanAdd {

test/Serialization/Inputs/has_xref.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public func numericArray(_ x: IntSlice) {}
1010

1111

1212
public protocol ExtraIncrementable {
13-
prefix func +++(base: inout Self)
13+
static prefix func +++(base: inout Self)
1414
}
1515

1616
extension SpecialInt : ExtraIncrementable {}

0 commit comments

Comments
 (0)