@@ -86,12 +86,16 @@ func test_invalid_refs_in_init_attrs() {
86
86
// expected-error@-2 {{find type 'b' in scope}}
87
87
// expected-error@-3 {{init accessor cannot refer to property 'c'; init accessors can refer only to stored properties}}
88
88
init( initialValue) { }
89
+
90
+ get { 0 }
89
91
}
90
92
91
93
var y : String {
92
94
@storageRestrictions ( initializes: test)
93
95
// expected-error@-1 {{ambiguous reference to member 'test'}}
94
96
init( initialValue) { }
97
+
98
+ get { " " }
95
99
}
96
100
97
101
func test( _: Int ) { } // expected-note {{'test' declared here}}
@@ -110,6 +114,8 @@ func test_assignment_to_let_properties() {
110
114
self . x = initialValue // Ok
111
115
self . y = 42 // expected-error {{cannot assign to property: 'y' is a 'let' constant}}
112
116
}
117
+
118
+ get { x }
113
119
}
114
120
115
121
var point : ( Int , Int ) {
@@ -157,6 +163,8 @@ func test_duplicate_and_computed_lazy_properties() {
157
163
// expected-error@-2 {{init accessor cannot refer to property 'b'; init accessors can refer only to stored properties}}
158
164
// expected-error@-3 {{init accessor cannot refer to property 'c'; init accessors can refer only to stored properties}}
159
165
init( initialValue) { }
166
+
167
+ get { _a }
160
168
}
161
169
162
170
var b : Int {
@@ -475,11 +483,15 @@ func test_default_arguments_are_analyzed() {
475
483
struct Test {
476
484
var pair : ( Int , Int ) = ( 0 , 1 ) { // Ok
477
485
init { }
486
+
487
+ get { ( 0 , 1 ) }
478
488
}
479
489
480
490
var other : ( Int , String ) = ( " " , 42 ) {
481
491
// expected-error@-1 {{cannot convert value of type '(String, Int)' to specified type '(Int, String)'}}
482
492
init ( initialValue) { }
493
+
494
+ get { ( 0 , " " ) }
483
495
}
484
496
485
497
var otherPair = ( 0 , 1 ) {
@@ -558,36 +570,47 @@ func test_invalid_storage_restrictions() {
558
570
@storageRestrictions ( )
559
571
// expected-error@-1 {{missing label in @storageRestrictions attribute}}
560
572
init { }
573
+
574
+ get { _a }
561
575
}
562
576
563
577
var b : Int {
564
578
@storageRestrictions ( initializes: )
565
579
// expected-error@-1 {{expected property name in @storageRestrictions list}}
566
580
init { }
581
+
582
+ get { _b }
567
583
}
568
584
569
585
var c : Int {
570
586
@storageRestrictions ( initializes: a, initializes: b)
571
587
// expected-error@-1 {{duplicate label 'initializes' in @storageRestrictions attribute}}
572
588
init { }
589
+
590
+ get { 0 }
573
591
}
574
592
575
593
var d : Int {
576
594
@storageRestrictions ( accesses: a, accesses: c)
577
595
// expected-error@-1 {{duplicate label 'accesses' in @storageRestrictions attribute}}
578
596
init { }
597
+
598
+ get { 0 }
579
599
}
580
600
581
601
var e : Int {
582
602
@storageRestrictions ( initialize: a, b, accesses: c, d)
583
603
// expected-error@-1 {{unexpected label 'initialize' in @storageRestrictions attribute}}
584
604
init { }
605
+
606
+ get { 0 }
585
607
}
586
608
587
609
var f : Int {
588
610
@storageRestrictions ( initializes: _a, accesses: _b, _a)
589
611
// expected-error@-1 {{property '_a' cannot be both initialized and accessed}}
590
612
init { }
613
+ // expected-error@-1 {{variable with an init accessor must also have a getter}}
591
614
}
592
615
593
616
var g : Int {
0 commit comments