You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
...and collapse StaticVar/ClassVar and StaticLet/ClassLet into
StaticProperty/ClassProperty.
"var" and "let" aren't great nouns to use in diagnostics to begin with,
especially alongside semantic terms like "instance method". Focus on
the type vs. non-type aspect instead with "property", which better
matches how people talk about member vars (and lets) anyway.
overrideinit(singleArgument:APPRefrigerator){} // expected-error {{initializer does not override a designated initializer from its superclass}}
80
80
81
81
// FIXME: expected-error@+2 {{getter for 'prop' with Objective-C selector 'prop' conflicts with getter for 'prop' from superclass 'Base' with the same Objective-C selector}}
82
-
// expected-note@+1 {{type does not match superclass var with type 'Refrigerator'}} {{22-37=Refrigerator}}
82
+
// expected-note@+1 {{type does not match superclass property with type 'Refrigerator'}} {{22-37=Refrigerator}}
83
83
overridevarprop:APPRefrigerator{ // expected-error {{property 'prop' with type 'APPRefrigerator' cannot override a property with type 'Refrigerator'}}
84
84
return super.prop asAPPRefrigerator
85
85
}
86
86
// FIXME: expected-error@+2 {{getter for 'propGeneric' with Objective-C selector 'propGeneric' conflicts with getter for 'propGeneric' from superclass 'Base' with the same Objective-C selector}}
87
-
// expected-note@+1 {{type does not match superclass var with type 'ManufacturerInfo<NSString>'}} {{29-59=ManufacturerInfo<NSString>}}
87
+
// expected-note@+1 {{type does not match superclass property with type 'ManufacturerInfo<NSString>'}} {{29-59=ManufacturerInfo<NSString>}}
88
88
overridevarpropGeneric:APPManufacturerInfo<AnyObject>{ // expected-error {{property 'propGeneric' with type 'APPManufacturerInfo<AnyObject>' cannot override a property with type 'ManufacturerInfo<NSString>'}}
Copy file name to clipboardExpand all lines: test/Compatibility/accessibility.swift
+10-10
Original file line number
Diff line number
Diff line change
@@ -183,7 +183,7 @@ internal extension Base {
183
183
publicclassPublicSub:Base{
184
184
privaterequiredinit(){} // expected-error {{'required' initializer must be accessible wherever class 'PublicSub' can be subclassed}} {{3-10=internal}}
185
185
overridefunc foo(){} // expected-error {{overriding instance method must be as accessible as the declaration it overrides}} {{12-12=public }}
186
-
overridevarbar:Int{ // expected-error {{overriding var must be as accessible as the declaration it overrides}} {{12-12=public }}
186
+
overridevarbar:Int{ // expected-error {{overriding property must be as accessible as the declaration it overrides}} {{12-12=public }}
187
187
get{return0}
188
188
set{}
189
189
}
@@ -197,7 +197,7 @@ public class PublicSubGood: Base {
197
197
internalclassInternalSub:Base{
198
198
requiredprivateinit(){} // expected-error {{'required' initializer must be accessible wherever class 'InternalSub' can be subclassed}} {{12-19=internal}}
199
199
privateoverridefunc foo(){} // expected-error {{overriding instance method must be as accessible as its enclosing type}} {{3-10=internal}}
200
-
privateoverridevarbar:Int{ // expected-error {{overriding var must be as accessible as its enclosing type}} {{3-10=internal}}
200
+
privateoverridevarbar:Int{ // expected-error {{overriding property must be as accessible as its enclosing type}} {{3-10=internal}}
201
201
get{return0}
202
202
set{}
203
203
}
@@ -216,7 +216,7 @@ internal class InternalSubGood: Base {
216
216
217
217
internalclassInternalSubPrivateSet:Base{
218
218
requiredinit(){}
219
-
private(set)overridevarbar:Int{ // expected-error {{overriding var must be as accessible as its enclosing type}} {{3-16=}}
219
+
private(set)overridevarbar:Int{ // expected-error {{overriding property must be as accessible as its enclosing type}} {{3-16=}}
220
220
get{return0}
221
221
set{}
222
222
}
@@ -229,7 +229,7 @@ internal class InternalSubPrivateSet: Base {
229
229
fileprivateclassFilePrivateSub:Base{
230
230
requiredprivateinit(){} // expected-error {{'required' initializer must be accessible wherever class 'FilePrivateSub' can be subclassed}} {{12-19=fileprivate}}
231
231
privateoverridefunc foo(){} // expected-error {{overriding instance method must be as accessible as its enclosing type}} {{3-10=fileprivate}}
232
-
privateoverridevarbar:Int{ // expected-error {{overriding var must be as accessible as its enclosing type}} {{3-10=fileprivate}}
232
+
privateoverridevarbar:Int{ // expected-error {{overriding property must be as accessible as its enclosing type}} {{3-10=fileprivate}}
233
233
get{return0}
234
234
set{}
235
235
}
@@ -258,7 +258,7 @@ fileprivate class FilePrivateSubGood2: Base {
258
258
259
259
fileprivateclassFilePrivateSubPrivateSet:Base{
260
260
requiredinit(){}
261
-
private(set)overridevarbar:Int{ // expected-error {{overriding var must be as accessible as its enclosing type}} {{3-10=fileprivate}}
261
+
private(set)overridevarbar:Int{ // expected-error {{overriding property must be as accessible as its enclosing type}} {{3-10=fileprivate}}
262
262
get{return0}
263
263
set{}
264
264
}
@@ -271,7 +271,7 @@ fileprivate class FilePrivateSubPrivateSet: Base {
271
271
privateclassPrivateSub:Base{
272
272
requiredprivateinit(){} // expected-error {{'required' initializer must be accessible wherever class 'PrivateSub' can be subclassed}} {{12-19=fileprivate}}
273
273
privateoverridefunc foo(){} // expected-error {{overriding instance method must be as accessible as its enclosing type}} {{3-10=fileprivate}}
274
-
privateoverridevarbar:Int{ // expected-error {{overriding var must be as accessible as its enclosing type}} {{3-10=fileprivate}}
274
+
privateoverridevarbar:Int{ // expected-error {{overriding property must be as accessible as its enclosing type}} {{3-10=fileprivate}}
275
275
get{return0}
276
276
set{}
277
277
}
@@ -291,7 +291,7 @@ private class PrivateSubGood: Base {
291
291
privateclassPrivateSubPrivateSet:Base{
292
292
requiredfileprivateinit(){}
293
293
fileprivateoverridefunc foo(){}
294
-
private(set)overridevarbar:Int{ // expected-error {{setter of overriding var must be as accessible as its enclosing type}}
294
+
private(set)overridevarbar:Int{ // expected-error {{setter of overriding property must be as accessible as its enclosing type}}
privatevarsize=0 // expected-error {{property 'size' must be declared internal because it matches a requirement in internal protocol 'InternalMutationOperations'}} {{none}} expected-note {{mark the var as 'internal' to satisfy the requirement}} {{3-10=internal}}
525
+
privatevarsize=0 // expected-error {{property 'size' must be declared internal because it matches a requirement in internal protocol 'InternalMutationOperations'}} {{none}} expected-note {{mark the property as 'internal' to satisfy the requirement}} {{3-10=internal}}
526
526
private subscript (_:Int)->Int{ // expected-error {{subscript must be declared internal because it matches a requirement in internal protocol 'InternalMutationOperations'}} {{none}} expected-note {{mark the subscript as 'internal' to satisfy the requirement}} {{3-10=internal}}
527
527
get{return42}
528
528
set{}
@@ -531,7 +531,7 @@ public struct AccessorsControl : InternalMutationOperations {
// Please don't change the formatting here; it's a precise fix-it test.
534
-
publicprivate(set)varsize=0 // expected-error {{setter for property 'size' must be declared internal because it matches a requirement in internal protocol 'InternalMutationOperations'}} {{none}} expected-note {{mark the var as 'internal' to satisfy the requirement}} {{10-17=internal}}
534
+
publicprivate(set)varsize=0 // expected-error {{setter for property 'size' must be declared internal because it matches a requirement in internal protocol 'InternalMutationOperations'}} {{none}} expected-note {{mark the property as 'internal' to satisfy the requirement}} {{10-17=internal}}
535
535
publicprivate(set) subscript (_:Int)->Int{ // expected-error {{subscript setter must be declared internal because it matches a requirement in internal protocol 'InternalMutationOperations'}} {{none}} expected-note {{mark the subscript as 'internal' to satisfy the requirement}} {{10-17=internal}}
536
536
get{return42}
537
537
set{}
@@ -540,7 +540,7 @@ public struct PrivateSettersPublic : InternalMutationOperations {
// Please don't change the formatting here; it's a precise fix-it test.
543
-
private(set)varsize=0 // expected-error {{setter for property 'size' must be as accessible as its enclosing type because it matches a requirement in protocol 'PublicMutationOperations'}} {{none}} expected-note {{mark the var as 'internal' to satisfy the requirement}} {{3-15=}}
543
+
private(set)varsize=0 // expected-error {{setter for property 'size' must be as accessible as its enclosing type because it matches a requirement in protocol 'PublicMutationOperations'}} {{none}} expected-note {{mark the property as 'internal' to satisfy the requirement}} {{3-15=}}
544
544
545
545
internalprivate(set)subscript (_:Int)->Int{ // expected-error {{subscript setter must be as accessible as its enclosing type because it matches a requirement in protocol 'PublicMutationOperations'}} {{none}} expected-note {{mark the subscript as 'internal' to satisfy the requirement}} {{12-24=}}
0 commit comments