Skip to content

Commit 905a6b4

Browse files
authored
Merge pull request #17053 from Moximillian/class-method-protocol-error-clarification-part2
Better error message for 'class func/var' usage in protocols (part 2)
2 parents ca2e874 + 596664f commit 905a6b4

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

include/swift/AST/DiagnosticsCommon.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ ERROR(super_not_in_class_method,none,
6666

6767
ERROR(class_func_not_in_class,none,
6868
"class methods are only allowed within classes; "
69-
"use 'static' to declare a%select{| requirement fulfilled by either a class or}0 static method", (bool))
69+
"use 'static' to declare a %select{static|requirement fulfilled by either a static or class}0 method", (bool))
7070
ERROR(class_var_not_in_class,none,
7171
"class properties are only allowed within classes; "
72-
"use 'static' to declare a%select{| requirement fulfilled by either a class or}0 static property", (bool))
72+
"use 'static' to declare a %select{static|requirement fulfilled by either a static or class}0 property", (bool))
7373

7474
// FIXME: Used by both the parser and the type-checker.
7575
ERROR(func_decl_without_brace,PointsToFirstBadToken,

test/decl/func/static_func.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ protocol P { // expected-note{{extended type declared here}}
110110
static func f2()
111111
static func f3() {} // expected-error {{protocol methods must not have bodies}}
112112
static final func f4() // expected-error {{only classes and class members may be marked with 'final'}}
113-
class func f5() // expected-error {{class methods are only allowed within classes; use 'static' to declare a requirement fulfilled by either a class or static method}} {{3-8=static}}
113+
class func f5() // expected-error {{class methods are only allowed within classes; use 'static' to declare a requirement fulfilled by either a static or class method}} {{3-8=static}}
114114
}
115115

116116
extension P {

test/decl/var/static_var.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,11 @@ extension C {
174174
protocol P { // expected-note{{did you mean 'P'?}} expected-note{{extended type declared here}}
175175
// Both `static` and `class` property requirements are equivalent in protocols rdar://problem/17198298
176176
static var v1: Int { get }
177-
class var v2: Int { get } // expected-error {{class properties are only allowed within classes; use 'static' to declare a requirement fulfilled by either a class or static property}} {{3-8=static}}
177+
class var v2: Int { get } // expected-error {{class properties are only allowed within classes; use 'static' to declare a requirement fulfilled by either a static or class property}} {{3-8=static}}
178178
static final var v3: Int { get } // expected-error {{only classes and class members may be marked with 'final'}}
179179

180180
static let l1: Int // expected-error {{immutable property requirement must be declared as 'var' with a '{ get }' specifier}}
181-
class let l2: Int // expected-error {{class properties are only allowed within classes; use 'static' to declare a requirement fulfilled by either a class or static property}} {{3-8=static}} expected-error {{immutable property requirement must be declared as 'var' with a '{ get }' specifier}}
181+
class let l2: Int // expected-error {{class properties are only allowed within classes; use 'static' to declare a requirement fulfilled by either a static or class property}} {{3-8=static}} expected-error {{immutable property requirement must be declared as 'var' with a '{ get }' specifier}}
182182
}
183183

184184
extension P {

0 commit comments

Comments
 (0)