File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -9541,15 +9541,27 @@ void AccessorDecl::printUserFacingName(raw_ostream &out) const {
9541
9541
9542
9542
ArrayRef<VarDecl *> AccessorDecl::getInitializedProperties () const {
9543
9543
assert (isInitAccessor ());
9544
+
9544
9545
if (auto *SR = getAttrs ().getAttribute <StorageRestrictionsAttr>())
9545
9546
return SR->getInitializesProperties (const_cast <AccessorDecl *>(this ));
9547
+
9548
+ // Fallback to old effect style declaration.
9549
+ if (auto *initAttr = getAttrs ().getAttribute <InitializesAttr>())
9550
+ return initAttr->getPropertyDecls (const_cast <AccessorDecl *>(this ));
9551
+
9546
9552
return {};
9547
9553
}
9548
9554
9549
9555
ArrayRef<VarDecl *> AccessorDecl::getAccessedProperties () const {
9550
9556
assert (isInitAccessor ());
9557
+
9551
9558
if (auto *SR = getAttrs ().getAttribute <StorageRestrictionsAttr>())
9552
9559
return SR->getAccessesProperties (const_cast <AccessorDecl *>(this ));
9560
+
9561
+ // Fallback to old effect style declaration.
9562
+ if (auto *accessAttr = getAttrs ().getAttribute <AccessesAttr>())
9563
+ return accessAttr->getPropertyDecls (const_cast <AccessorDecl *>(this ));
9564
+
9553
9565
return {};
9554
9566
}
9555
9567
Original file line number Diff line number Diff line change @@ -538,3 +538,25 @@ test_init_accessors_without_setters()
538
538
// CHECK: test-without-setter1: 42
539
539
// CHECK-NEXT: test-without-setter2: [1, 2, 3]
540
540
// CHECK-NEXT: test-without-setter3: ["a", "b", "c"]
541
+
542
+ func test_effects_are_still_supported( ) {
543
+ struct Test {
544
+ var _a : Int
545
+ var _b : Int
546
+
547
+ var a : Int {
548
+ init ( initialValue) initializes( _a) accesses( _b) {
549
+ _a = initialValue
550
+ _b = 0
551
+ }
552
+
553
+ get { _a }
554
+ }
555
+ }
556
+
557
+ let test = Test ( _b: 1 , a: 42 )
558
+ print ( " effects-support-test: \( test) " )
559
+ }
560
+
561
+ test_effects_are_still_supported ( )
562
+ // CHEKC: effects-support-test: Test(_a: 42, b: 0)
You can’t perform that action at this time.
0 commit comments