Skip to content

Commit e659bef

Browse files
committed
Sema: Clean up wording in some attribute-related diagnostics
1 parent 29279af commit e659bef

File tree

7 files changed

+36
-36
lines changed

7 files changed

+36
-36
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,9 +1028,9 @@ ERROR(static_functions_not_mutating,none,
10281028
"static functions must not be declared mutating", ())
10291029

10301030
ERROR(transparent_in_protocols_not_supported,none,
1031-
"@_transparent is not supported on declarations within protocols", ())
1031+
"'@_transparent' attribute is not supported on declarations within protocols", ())
10321032
ERROR(transparent_in_classes_not_supported,none,
1033-
"@_transparent is not supported on declarations within classes", ())
1033+
"'@_transparent' attribute is not supported on declarations within classes", ())
10341034

10351035
ERROR(invalid_iboutlet,none,
10361036
"only instance properties can be declared @IBOutlet", ())
@@ -1124,7 +1124,7 @@ ERROR(access_control_open_bad_decl,none,
11241124
ERROR(invalid_decl_attribute_simple,none,
11251125
"attribute cannot be applied to declaration", ())
11261126
ERROR(invalid_decl_attribute,none,
1127-
"%0 cannot be applied to this declaration", (DeclAttribute))
1127+
"'%0' attribute cannot be applied to this declaration", (DeclAttribute))
11281128
ERROR(invalid_decl_modifier,none,
11291129
"%0 modifier cannot be applied to this declaration", (DeclAttribute))
11301130
ERROR(attribute_does_not_apply_to_type,none,
@@ -3707,7 +3707,7 @@ ERROR(class_designated_init_inlineable_resilient,none,
37073707
"delegate to another initializer", (Type, unsigned))
37083708

37093709
ERROR(attribute_invalid_on_stored_property,
3710-
none, "@%0 cannot be applied to stored properties", (StringRef))
3710+
none, "'@%0' attribute cannot be applied to stored properties", (StringRef))
37113711

37123712
ERROR(inlineable_dynamic_not_supported,
37133713
none, "'@_inlineable' attribute cannot be applied to 'dynamic' declarations", ())

test/attr/attr_inlineable.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// RUN: %target-typecheck-verify-swift -swift-version 4 -enable-testing
33

44
@_inlineable struct TestInlineableStruct {}
5-
// expected-error@-1 {{@_inlineable cannot be applied to this declaration}}
5+
// expected-error@-1 {{'@_inlineable' attribute cannot be applied to this declaration}}
66

77
private func privateFunction() {}
88
// expected-note@-1{{global function 'privateFunction()' is not '@_versioned' or public}}
@@ -24,10 +24,10 @@ public struct PublicStruct {
2424
public init() {}
2525

2626
@_inlineable public var storedProperty: Int
27-
// expected-error@-1 {{@_inlineable cannot be applied to stored properties}}
27+
// expected-error@-1 {{'@_inlineable' attribute cannot be applied to stored properties}}
2828

2929
@_inlineable public lazy var lazyProperty: Int = 0
30-
// expected-error@-1 {{@_inlineable cannot be applied to stored properties}}
30+
// expected-error@-1 {{'@_inlineable' attribute cannot be applied to stored properties}}
3131
}
3232

3333
public struct Struct {

test/attr/attr_nonobjc.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ class BlueLightSaber : LightSaber {
3939
init(x: String) {} // expected-error {{conflicts with previous declaration with the same Objective-C selector}}
4040
}
4141

42-
@nonobjc class NonObjCClassNotAllowed { } // expected-error {{@nonobjc cannot be applied to this declaration}} {{1-10=}}
42+
@nonobjc class NonObjCClassNotAllowed { } // expected-error {{'@nonobjc' attribute cannot be applied to this declaration}} {{1-10=}}
4343

4444
class NonObjCDeallocNotAllowed {
45-
@nonobjc deinit { // expected-error {{@nonobjc cannot be applied to this declaration}} {{3-12=}}
45+
@nonobjc deinit { // expected-error {{'@nonobjc' attribute cannot be applied to this declaration}} {{3-12=}}
4646

4747
}
4848
}

test/attr/attr_objc.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func subject_genericFunc<T>(t: T) { // expected-error {{@objc can only be used w
121121
func subject_funcParam(a: @objc Int) { // expected-error {{attribute can only be applied to declarations, not types}} {{1-1=@objc }} {{27-33=}}
122122
}
123123

124-
@objc // expected-error {{@objc cannot be applied to this declaration}} {{1-7=}}
124+
@objc // expected-error {{'@objc' attribute cannot be applied to this declaration}} {{1-7=}}
125125
struct subject_struct {
126126
@objc
127127
var subject_instanceVar: Int // expected-error {{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}} {{3-8=}}
@@ -133,7 +133,7 @@ struct subject_struct {
133133
func subject_instanceFunc() {} // expected-error {{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}} {{3-8=}}
134134
}
135135

136-
@objc // expected-error {{@objc cannot be applied to this declaration}} {{1-7=}}
136+
@objc // expected-error {{'@objc' attribute cannot be applied to this declaration}} {{1-7=}}
137137
struct subject_genericStruct<T> {
138138
@objc
139139
var subject_instanceVar: Int // expected-error {{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}} {{3-8=}}
@@ -209,7 +209,7 @@ enum subject_enum: Int {
209209
@objc // expected-error {{attribute has no effect; cases within an '@objc' enum are already exposed to Objective-C}} {{3-9=}}
210210
case subject_enumElement5, subject_enumElement6
211211

212-
@nonobjc // expected-error {{@nonobjc cannot be applied to this declaration}}
212+
@nonobjc // expected-error {{'@nonobjc' attribute cannot be applied to this declaration}}
213213
case subject_enumElement7
214214

215215
@objc

test/attr/attr_versioned.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fileprivate class filePrivateClass {
3131
}
3232

3333
@_versioned extension S {}
34-
// expected-error@-1 {{@_versioned cannot be applied to this declaration}}
34+
// expected-error@-1 {{'@_versioned' attribute cannot be applied to this declaration}}
3535

3636
@_versioned
3737
protocol VersionedProtocol {

test/attr/attributes.swift

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ func f5(x: inout binary) {}
1717

1818
@IBDesignable
1919
class IBDesignableClassTy {
20-
@IBDesignable func foo() {} // expected-error {{@IBDesignable cannot be applied to this declaration}} {{3-17=}}
20+
@IBDesignable func foo() {} // expected-error {{'@IBDesignable' attribute cannot be applied to this declaration}} {{3-17=}}
2121
}
2222

23-
@IBDesignable // expected-error {{@IBDesignable cannot be applied to this declaration}} {{1-15=}}
23+
@IBDesignable // expected-error {{'@IBDesignable' attribute cannot be applied to this declaration}} {{1-15=}}
2424
struct IBDesignableStructTy {}
2525

26-
@IBDesignable // expected-error {{@IBDesignable cannot be applied to this declaration}} {{1-15=}}
26+
@IBDesignable // expected-error {{'@IBDesignable' attribute cannot be applied to this declaration}} {{1-15=}}
2727
protocol IBDesignableProtTy {}
2828

2929
@IBDesignable // expected-error {{@IBDesignable can only be applied to classes and extensions of classes}} {{1-15=}}
@@ -54,21 +54,21 @@ func foo(x: @convention(block) (Int) -> Int) {}
5454
func zim() {}
5555
@_transparent
5656
func zung<T>(_: T) {}
57-
@_transparent // expected-error{{@_transparent cannot be applied to stored properties}} {{1-15=}}
57+
@_transparent // expected-error{{'@_transparent' attribute cannot be applied to stored properties}} {{1-15=}}
5858
var zippity : Int
5959
func zoom(x: @_transparent () -> ()) { } // expected-error{{attribute can only be applied to declarations, not types}} {{1-1=@_transparent }} {{14-28=}}
6060
protocol ProtoWithTransparent {
61-
@_transparent// expected-error{{@_transparent is not supported on declarations within protocols}} {{3-16=}}
61+
@_transparent// expected-error{{'@_transparent' attribute is not supported on declarations within protocols}} {{3-16=}}
6262
func transInProto()
6363
}
6464
class TestTranspClass : ProtoWithTransparent {
65-
@_transparent // expected-error{{@_transparent is not supported on declarations within classes}} {{3-17=}}
65+
@_transparent // expected-error{{'@_transparent' attribute is not supported on declarations within classes}} {{3-17=}}
6666
init () {}
67-
@_transparent // expected-error{{@_transparent cannot be applied to this declaration}} {{3-17=}}
67+
@_transparent // expected-error{{'@_transparent' attribute cannot be applied to this declaration}} {{3-17=}}
6868
deinit {}
69-
@_transparent // expected-error{{@_transparent is not supported on declarations within classes}} {{3-17=}}
69+
@_transparent // expected-error{{'@_transparent' attribute is not supported on declarations within classes}} {{3-17=}}
7070
class func transStatic() {}
71-
@_transparent// expected-error{{@_transparent is not supported on declarations within classes}} {{3-16=}}
71+
@_transparent// expected-error{{'@_transparent' attribute is not supported on declarations within classes}} {{3-16=}}
7272
func transInProto() {}
7373
}
7474
struct TestTranspStruct : ProtoWithTransparent{
@@ -81,33 +81,33 @@ struct TestTranspStruct : ProtoWithTransparent{
8181
@_transparent
8282
func transInProto() {}
8383
}
84-
@_transparent // expected-error{{@_transparent cannot be applied to this declaration}} {{1-15=}}
84+
@_transparent // expected-error{{'@_transparent' attribute cannot be applied to this declaration}} {{1-15=}}
8585
struct CannotHaveTransparentStruct {
8686
func m1() {}
8787
}
88-
@_transparent // expected-error{{@_transparent cannot be applied to this declaration}} {{1-15=}}
88+
@_transparent // expected-error{{'@_transparent' attribute cannot be applied to this declaration}} {{1-15=}}
8989
extension TestTranspClass {
9090
func tr1() {}
9191
}
92-
@_transparent // expected-error{{@_transparent cannot be applied to this declaration}} {{1-15=}}
92+
@_transparent // expected-error{{'@_transparent' attribute cannot be applied to this declaration}} {{1-15=}}
9393
extension TestTranspStruct {
9494
func tr1() {}
9595
}
96-
@_transparent // expected-error{{@_transparent cannot be applied to this declaration}} {{1-15=}}
96+
@_transparent // expected-error{{'@_transparent' attribute cannot be applied to this declaration}} {{1-15=}}
9797
extension binary {
9898
func tr1() {}
9999
}
100100

101101
class transparentOnClassVar {
102-
@_transparent var max: Int { return 0xFF }; // expected-error {{@_transparent is not supported on declarations within classes}} {{3-17=}}
102+
@_transparent var max: Int { return 0xFF }; // expected-error {{'@_transparent' attribute is not supported on declarations within classes}} {{3-17=}}
103103
func blah () {
104104
var _: Int = max
105105
}
106106
};
107107

108108
class transparentOnClassVar2 {
109109
var max: Int {
110-
@_transparent // expected-error {{@_transparent is not supported on declarations within classes}} {{5-19=}}
110+
@_transparent // expected-error {{'@_transparent' attribute is not supported on declarations within classes}} {{5-19=}}
111111
get {
112112
return 0xFF
113113
}
@@ -206,18 +206,18 @@ func func_type_attribute_with_space(x: @convention (c) () -> Int) {} // OK. Know
206206
var thinFunc : @thin () -> () // expected-error {{attribute is not supported}}
207207

208208
@inline(never) func nolineFunc() {}
209-
@inline(never) var noinlineVar : Int // expected-error {{@inline(never) cannot be applied to this declaration}} {{1-16=}}
210-
@inline(never) class FooClass { // expected-error {{@inline(never) cannot be applied to this declaration}} {{1-16=}}
209+
@inline(never) var noinlineVar : Int // expected-error {{'@inline(never)' attribute cannot be applied to this declaration}} {{1-16=}}
210+
@inline(never) class FooClass { // expected-error {{'@inline(never)' attribute cannot be applied to this declaration}} {{1-16=}}
211211
}
212212

213213
@inline(__always) func AlwaysInlineFunc() {}
214-
@inline(__always) var alwaysInlineVar : Int // expected-error {{@inline(__always) cannot be applied to this declaration}} {{1-19=}}
215-
@inline(__always) class FooClass2 { // expected-error {{@inline(__always) cannot be applied to this declaration}} {{1-19=}}
214+
@inline(__always) var alwaysInlineVar : Int // expected-error {{'@inline(__always)' attribute cannot be applied to this declaration}} {{1-19=}}
215+
@inline(__always) class FooClass2 { // expected-error {{'@inline(__always)' attribute cannot be applied to this declaration}} {{1-19=}}
216216
}
217217

218218
@_optimize(speed) func OspeedFunc() {}
219-
@_optimize(speed) var OpeedVar : Int // expected-error {{@_optimize(speed) cannot be applied to stored properties}} {{1-19=}}
220-
@_optimize(speed) class OspeedClass { // expected-error {{@_optimize(speed) cannot be applied to this declaration}} {{1-19=}}
219+
@_optimize(speed) var OpeedVar : Int // expected-error {{'@_optimize(speed)' attribute cannot be applied to stored properties}} {{1-19=}}
220+
@_optimize(speed) class OspeedClass { // expected-error {{'@_optimize(speed)' attribute cannot be applied to this declaration}} {{1-19=}}
221221
}
222222

223223
class A {
@@ -251,7 +251,7 @@ class C {
251251
@_optimize(size) set {
252252
}
253253
}
254-
@_optimize(size) var c : Int // expected-error {{@_optimize(size) cannot be applied to stored properties}}
254+
@_optimize(size) var c : Int // expected-error {{'@_optimize(size)' attribute cannot be applied to stored properties}}
255255
}
256256

257257
class SILStored {

test/decl/var/NSManaged_properties.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class X : NSObject {
88
func foo() -> X { return self }
99
}
1010

11-
@NSManaged struct SomeStruct {} // expected-error {{@NSManaged cannot be applied to this declaration}}
11+
@NSManaged struct SomeStruct {} // expected-error {{'@NSManaged' attribute cannot be applied to this declaration}}
1212

1313
@NSManaged var global: Int // expected-error {{@NSManaged only allowed on an instance property or method}}
1414

0 commit comments

Comments
 (0)