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 @@ -9529,15 +9529,27 @@ void AccessorDecl::printUserFacingName(raw_ostream &out) const {
9529
9529
9530
9530
ArrayRef<VarDecl *> AccessorDecl::getInitializedProperties () const {
9531
9531
assert (isInitAccessor ());
9532
+
9532
9533
if (auto *SR = getAttrs ().getAttribute <StorageRestrictionsAttr>())
9533
9534
return SR->getInitializesProperties (const_cast <AccessorDecl *>(this ));
9535
+
9536
+ // Fallback to old effect style declaration.
9537
+ if (auto *initAttr = getAttrs ().getAttribute <InitializesAttr>())
9538
+ return initAttr->getPropertyDecls (const_cast <AccessorDecl *>(this ));
9539
+
9534
9540
return {};
9535
9541
}
9536
9542
9537
9543
ArrayRef<VarDecl *> AccessorDecl::getAccessedProperties () const {
9538
9544
assert (isInitAccessor ());
9545
+
9539
9546
if (auto *SR = getAttrs ().getAttribute <StorageRestrictionsAttr>())
9540
9547
return SR->getAccessesProperties (const_cast <AccessorDecl *>(this ));
9548
+
9549
+ // Fallback to old effect style declaration.
9550
+ if (auto *accessAttr = getAttrs ().getAttribute <AccessesAttr>())
9551
+ return accessAttr->getPropertyDecls (const_cast <AccessorDecl *>(this ));
9552
+
9541
9553
return {};
9542
9554
}
9543
9555
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