Skip to content

Commit bdf662a

Browse files
committed
[CoroutineAccessors] Default impls are transparent
Like every other method entry in the default witness table, the default implementations of the `read2` and `modify2` accessors that just call `read` and `modify` respectively should be transparent.
1 parent 563f932 commit bdf662a

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

lib/Sema/TypeCheckStorage.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2828,6 +2828,11 @@ IsAccessorTransparentRequest::evaluate(Evaluator &evaluator,
28282828
if (accessor->getAttrs().hasAttribute<TransparentAttr>())
28292829
return true;
28302830

2831+
// Default implementations of read2 and modify2 provided for back-deployment
2832+
// are transparent.
2833+
if (accessor->isRequirementWithSynthesizedDefaultImplementation())
2834+
return true;
2835+
28312836
if (!accessor->isImplicit())
28322837
return false;
28332838

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// RUN: %target-swift-emit-silgen \
2+
// RUN: %s \
3+
// RUN: -experimental-skip-non-inlinable-function-bodies \
4+
// RUN: -enable-library-evolution \
5+
// RUN: -enable-experimental-feature CoroutineAccessors \
6+
// RUN: | %FileCheck %s --check-prefixes=CHECK,CHECK-NOUNWIND
7+
8+
// RUN: %target-swift-emit-silgen \
9+
// RUN: %s \
10+
// RUN: -experimental-skip-non-inlinable-function-bodies \
11+
// RUN: -enable-library-evolution \
12+
// RUN: -enable-experimental-feature CoroutineAccessors \
13+
// RUN: -enable-experimental-feature CoroutineAccessorsUnwindOnCallerError \
14+
// RUN: | %FileCheck %s --check-prefixes=CHECK,CHECK-UNWIND
15+
16+
// REQUIRES: swift_feature_CoroutineAccessors
17+
// REQUIRES: swift_feature_CoroutineAccessorsUnwindOnCallerError
18+
19+
// CHECK-LABEL: sil_default_witness_table MutatableAssociatedField {
20+
// CHECK-NEXT: no_default
21+
// CHECK-NEXT: no_default
22+
// CHECK-NEXT: method #MutatableAssociatedField.field!read2
23+
// CHECK-SAME: : @$s24coroutine_accessors_skip24MutatableAssociatedFieldP5field5AssocQzvy
24+
// CHECK-NEXT: no_default
25+
// CHECK-NEXT: no_default
26+
// CHECK-NEXT: method #MutatableAssociatedField.field!modify2
27+
// CHECK-SAME: : @$s24coroutine_accessors_skip24MutatableAssociatedFieldP5field5AssocQzvx
28+
// CHECK-NEXT: }
29+
public protocol MutatableAssociatedField {
30+
associatedtype Assoc
31+
32+
var field: Assoc { read set }
33+
}

test/SILGen/read_requirements.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public protocol P1 : ~Copyable {
5555
// CHECK: unwind
5656
// CHECK-LABEL: } // end sil function '$s17read_requirements2P1P4ubgsAA1UVvy'
5757

58-
// CHECK-LABEL: sil [ossa] @$s17read_requirements2P1P4ubgsAA1UVvx : {{.*}} {
58+
// CHECK-LABEL: sil{{.*}} [ossa] @$s17read_requirements2P1P4ubgsAA1UVvx : {{.*}} {
5959
// CHECK: bb0(
6060
// CHECK-SAME: [[SELF_UNCHECKED:%[^:]+]]
6161
// CHECK-SAME: ):

0 commit comments

Comments
 (0)