Skip to content

Commit e2d01f5

Browse files
committed
[Parse] Upgrade operator_static_in_protocol to Swift 4 error.
Part of rdar://problem/28961650 .
1 parent 2e512cb commit e2d01f5

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
@@ -4719,11 +4719,15 @@ Parser::parseDeclFunc(SourceLoc StaticLoc, StaticSpellingKind StaticSpelling,
47194719
// Within a protocol, recover from a missing 'static'.
47204720
if (Flags & PD_InProtocol) {
47214721
switch (StaticSpelling) {
4722-
case StaticSpellingKind::None:
4723-
diagnose(NameLoc, diag::operator_static_in_protocol, SimpleName.str())
4724-
.fixItInsert(FuncLoc, "static ");
4722+
case StaticSpellingKind::None: {
4723+
auto Message = Context.isSwiftVersion3()
4724+
? diag::swift3_operator_static_in_protocol
4725+
: diag::operator_static_in_protocol;
4726+
diagnose(NameLoc, Message, SimpleName.str())
4727+
.fixItInsert(FuncLoc, "static ");
47254728
StaticSpelling = StaticSpellingKind::KeywordStatic;
47264729
break;
4730+
}
47274731

47284732
case StaticSpellingKind::KeywordStatic:
47294733
// 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)