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
Copy file name to clipboardExpand all lines: test/decl/protocol/protocols.swift
+9-6Lines changed: 9 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -14,15 +14,18 @@ protocol Test {
14
14
varcreator:String{get}
15
15
varmajor:Int{get}
16
16
varminor:Int{get}
17
-
var subminor :Int // expected-error {{property in protocol must have explicit { get } or { get set } specifier}}
18
-
staticvar staticProperty:Int // expected-error{{property in protocol must have explicit { get } or { get set } specifier}}
17
+
var subminor :Int // expected-error {{property in protocol must have explicit { get } or { get set } specifier}} {{21-21= { get <#set#> \}}}
18
+
staticvar staticProperty:Int // expected-error{{property in protocol must have explicit { get } or { get set } specifier}} {{33-33= { get <#set#> \}}}
19
+
20
+
let bugfix // expected-error {{type annotation missing in pattern}} expected-error {{immutable property requirement must be declared as 'var' with a '{ get }' specifier}}
21
+
var comment // expected-error {{type annotation missing in pattern}} expected-error {{property in protocol must have explicit { get } or { get set } specifier}}
19
22
}
20
23
21
24
protocolTest2{
22
25
varproperty:Int{get}
23
26
24
-
vartitle:String="The Art of War"{get} // expected-error{{initial value is not allowed here}} expected-error {{property in protocol must have explicit { get } or { get set } specifier}}
25
-
staticvar title2:String="The Art of War" // expected-error{{initial value is not allowed here}} expected-error {{property in protocol must have explicit { get } or { get set } specifier}}
27
+
vartitle:String="The Art of War"{get} // expected-error{{initial value is not allowed here}} expected-error {{property in protocol must have explicit { get } or { get set } specifier}} {{20-20= { get <#set#> \}}}
28
+
staticvar title2:String="The Art of War" // expected-error{{initial value is not allowed here}} expected-error {{property in protocol must have explicit { get } or { get set } specifier}} {{28-28= { get <#set#> \}}}
26
29
27
30
associatedtypemytype
28
31
associatedtypemybadtype=Int
@@ -454,7 +457,7 @@ protocol ShouldntCrash {
454
457
letfullName:String{get} // expected-error {{'let' declarations cannot be computed properties}} {{3-6=var}}
455
458
456
459
// <rdar://problem/17200672> Let in protocol causes unclear errors and crashes
457
-
let fullName2:String // expected-error {{immutable property requirement must be declared as 'var' with a '{ get }' specifier}}
460
+
let fullName2:String // expected-error {{immutable property requirement must be declared as 'var' with a '{ get }' specifier}} {{3-6=var}} {{24-24= { get \}}}
458
461
459
462
// <rdar://problem/16789886> Assert on protocol property requirement without a type
460
463
varpropertyWithoutType{get} // expected-error {{type annotation missing in pattern}}
@@ -500,7 +503,7 @@ class C4 : P4 { // expected-error {{type 'C4' does not conform to protocol 'P4'}
500
503
// <rdar://problem/25185722> Crash with invalid 'let' property in protocol
501
504
protocolLetThereBeCrash{
502
505
let x:Int
503
-
// expected-error@-1 {{immutable property requirement must be declared as 'var' with a '{ get }' specifier}}
506
+
// expected-error@-1 {{immutable property requirement must be declared as 'var' with a '{ get }' specifier}} {{13-13= { get \}}}
Copy file name to clipboardExpand all lines: test/decl/subscript/subscripting.swift
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -346,9 +346,9 @@ class Foo {
346
346
protocolr23952125{
347
347
associatedtypeItemType
348
348
varcount:Int{get}
349
-
subscript(index:Int)-> ItemType // expected-error {{subscript in protocol must have explicit { get } or { get set } specifier}} {{36-36= { get set \}}}
350
-
351
-
var c : Int // expected-error {{property in protocol must have explicit { get } or { get set } specifier}}
349
+
subscript(index:Int)-> ItemType // expected-error {{subscript in protocol must have explicit { get } or { get set } specifier}} {{36-36= { get <#set#> \}}}
350
+
351
+
var c : Int // expected-error {{property in protocol must have explicit { get } or { get set } specifier}} {{14-14= { get <#set#> \}}}
352
352
}
353
353
354
354
// <rdar://problem/16812341> QoI: Poor error message when providing a default value for a subscript parameter
var a:Int // expected-error {{property in protocol must have explicit { get } or { get set } specifier}}
853
+
var a:Int // expected-error {{property in protocol must have explicit { get } or { get set } specifier}} {{13-13= { get <#set#> \}}}
854
854
}
855
855
protocolProtocolGetSet2{
856
-
vara:Int{} // expected-error {{property in protocol must have explicit { get } or { get set } specifier}}
856
+
vara:Int{} // expected-error {{property in protocol must have explicit { get } or { get set } specifier}} {{14-16={ get <#set#> \}}}
857
857
}
858
858
protocolProtocolGetSet3{
859
859
vara:Int{get}
@@ -869,16 +869,20 @@ protocol ProtocolGetSet6 {
869
869
}
870
870
871
871
protocolProtocolWillSetDidSet1{
872
-
vara:Int{ willSet } // expected-error {{property in protocol must have explicit { get } or { get set } specifier}} expected-error {{expected get or set in a protocol property}}
872
+
vara:Int{ willSet } // expected-error {{property in protocol must have explicit { get } or { get set } specifier}} {{14-25={ get <#set#> \}}} expected-error {{expected get or set in a protocol property}}
873
873
}
874
874
protocolProtocolWillSetDidSet2{
875
-
vara:Int{ didSet } // expected-error {{property in protocol must have explicit { get } or { get set } specifier}} expected-error {{expected get or set in a protocol property}}
875
+
vara:Int{ didSet } // expected-error {{property in protocol must have explicit { get } or { get set } specifier}} {{14-24={ get <#set#> \}}} expected-error {{expected get or set in a protocol property}}
876
876
}
877
877
protocolProtocolWillSetDidSet3{
878
-
vara:Int{ willSet didSet } // expected-error {{property in protocol must have explicit { get } or { get set } specifier}} expected-error 2 {{expected get or set in a protocol property}}
878
+
vara:Int{ willSet didSet } // expected-error {{property in protocol must have explicit { get } or { get set } specifier}} {{14-32={ get <#set#> \}}} expected-error 2 {{expected get or set in a protocol property}}
879
+
879
880
}
880
881
protocolProtocolWillSetDidSet4{
881
-
vara:Int{ didSet willSet } // expected-error {{property in protocol must have explicit { get } or { get set } specifier}} expected-error 2 {{expected get or set in a protocol property}}
882
+
vara:Int{ didSet willSet } // expected-error {{property in protocol must have explicit { get } or { get set } specifier}} {{14-32={ get <#set#> \}}} expected-error 2 {{expected get or set in a protocol property}}
883
+
}
884
+
protocolProtocolWillSetDidSet5{
885
+
leta:Int{ didSet willSet } // expected-error {{property in protocol must have explicit { get } or { get set } specifier}} {{14-32={ get <#set#> \}}} {{none}} expected-error 2 {{expected get or set in a protocol property}} expected-error {{'let' declarations cannot be computed properties}} {{3-6=var}}
882
886
}
883
887
884
888
varglobalDidsetWillSet:Int{ // expected-error {{non-member observing properties require an initializer}}
0 commit comments