Unbreak tests after read / modify accessors added

This commit is contained in:
Anton Korobeynikov
2025-01-07 13:58:29 -08:00
parent 0b345097e0
commit 4eb5d62df6
14 changed files with 68 additions and 62 deletions

View File

@@ -1155,8 +1155,14 @@ public:
SmallVector<AnyFunctionType::Yield, 4> buffer;
auto TheFunc = AnyFunctionRef::fromDeclContext(DC);
auto yieldResults = TheFunc->getBodyYieldResults(buffer);
// Checking yields requires proper interface type. If decl is invalid, then
// we already emitted diagnostics elsewhere.
if (auto *AFD = TheFunc->getAbstractFunctionDecl()) {
if (AFD->isInvalid())
return YS;
}
auto yieldResults = TheFunc->getBodyYieldResults(buffer);
auto yieldExprs = YS->getMutableYields();
if (yieldExprs.size() != yieldResults.size()) {
getASTContext().Diags.diagnose(YS->getYieldLoc(), diag::bad_yield_count,

View File

@@ -2554,7 +2554,7 @@ createCoroutineAccessorPrototype(AbstractStorageDecl *storage,
// Coroutine accessors yields storage value types
const Type retTy = YieldResultType::get(storage->getValueInterfaceType(),
kind == AccessorKind::Modify);
isYieldingMutableAccessor(kind));
auto *accessor = AccessorDecl::create(
ctx, loc, /*AccessorKeywordLoc=*/SourceLoc(), kind, storage,

View File

@@ -28,19 +28,19 @@ sil @B_i_modify : $@yield_once @convention(method) (@guaranteed B) -> @yields @i
sil @B_i_modify2 : $@yield_once_2 @convention(method) (@guaranteed B) -> @yields @inout Int
sil_vtable B {
#B.i!read: (B) -> () -> () : @B_i_read
#B.i!read2: (B) -> () -> () : @B_i_read2
#B.i!read: (B) -> @yield_once () -> @yields Int : @B_i_read
#B.i!read2: (B) -> @yield_once () -> @yields Int : @B_i_read2
#B.i!setter: (B) -> (Int) -> () : @B_i_set
#B.i!modify: (B) -> () -> () : @B_i_modify
#B.i!modify2: (B) -> () -> () : @B_i_modify2
#B.i!modify: (B) -> @yield_once () -> inout @yields Int : @B_i_modify
#B.i!modify2: (B) -> @yield_once () -> inout @yields Int : @B_i_modify2
}
sil @B_i_read2_default_override : $@yield_once_2 @convention(method) (@guaranteed B) -> @yields Int
sil @B_i_modify2_default_override : $@yield_once_2 @convention(method) (@guaranteed B) -> @yields @inout Int
sil_default_override_table B {
#B.i!read2: #B.i!read: (B) -> () -> () : @B_i_read2_default_override
#B.i!modify2: #B.i!modify: (B) -> () -> () : @B_i_modify2_default_override
#B.i!read2: #B.i!read: (B) -> @yield_once () -> @yields Int : @B_i_read2_default_override
#B.i!modify2: #B.i!modify: (B) -> @yield_once () -> inout @yields Int : @B_i_modify2_default_override
}
// CHECK: %swift.method_default_override_descriptor = type { i32, i32, i32 }

View File

@@ -17,7 +17,7 @@ func read<T>(_ c : () -> T) -> T { c() }
// disabled: ok!
var im : Int {
modify { // expected-enabled-error{{variable with a 'modify' accessor must also have a getter, addressor, or 'read' accessor}}
1 // expected-enabled-warning{{integer literal is unused}}
1 // expected-enabled-error{{unexpected non-void return value in void function}}
}
}
@@ -25,6 +25,6 @@ var im : Int {
// disabled: ok!
var ir : Int {
read {
1 // expected-enabled-warning{{integer literal is unused}}
1 // expected-enabled-error{{unexpected non-void return value in void function}}
}
}

View File

@@ -24,21 +24,21 @@ sil @B_i_modify : $@yield_once @convention(method) (@guaranteed B) -> @yields @i
sil @B_i_modify2 : $@yield_once_2 @convention(method) (@guaranteed B) -> @yields @inout Int
sil_vtable B {
#B.i!read: (B) -> () -> () : @B_i_read
#B.i!read2: (B) -> () -> () : @B_i_read2
#B.i!read: (B) -> @yield_once () -> @yields Int : @B_i_read
#B.i!read2: (B) -> @yield_once () -> @yields Int : @B_i_read2
#B.i!setter: (B) -> (Int) -> () : @B_i_set
#B.i!modify: (B) -> () -> () : @B_i_modify
#B.i!modify2: (B) -> () -> () : @B_i_modify2
#B.i!modify: (B) -> @yield_once () -> inout @yields Int : @B_i_modify
#B.i!modify2: (B) -> @yield_once () -> inout @yields Int : @B_i_modify2
}
sil @B_i_read2_default_override : $@yield_once_2 @convention(method) (@guaranteed B) -> @yields Int
sil @B_i_modify2_default_override : $@yield_once_2 @convention(method) (@guaranteed B) -> @yields @inout Int
// CHECK-LABEL: sil_default_override_table B {
// CHECK-NEXT: #B.i!read2: #B.i!read: (B) -> () -> () : @B_i_read2_default_override
// CHECK-NEXT: #B.i!modify2: #B.i!modify: (B) -> () -> () : @B_i_modify2_default_override
// CHECK-NEXT: #B.i!read2: #B.i!read: (B) -> @yield_once () -> @yields Int : @B_i_read2_default_override
// CHECK-NEXT: #B.i!modify2: #B.i!modify: (B) -> @yield_once () -> inout @yields Int : @B_i_modify2_default_override
// CHECK-NEXT: }
sil_default_override_table B {
#B.i!read2: #B.i!read: (B) -> () -> () : @B_i_read2_default_override
#B.i!modify2: #B.i!modify: (B) -> () -> () : @B_i_modify2_default_override
#B.i!read2: #B.i!read: (B) -> @yield_once () -> @yields Int : @B_i_read2_default_override
#B.i!modify2: #B.i!modify: (B) -> @yield_once () -> inout @yields Int : @B_i_modify2_default_override
}

View File

@@ -26,21 +26,21 @@ sil @B_i_modify : $@yield_once @convention(method) (@guaranteed B) -> @yields @i
sil @B_i_modify2 : $@yield_once_2 @convention(method) (@guaranteed B) -> @yields @inout Int
sil_vtable B {
#B.i!read: (B) -> () -> () : @B_i_read
#B.i!read2: (B) -> () -> () : @B_i_read2
#B.i!read: (B) -> @yield_once () -> @yields Int : @B_i_read
#B.i!read2: (B) -> @yield_once () -> @yields Int : @B_i_read2
#B.i!setter: (B) -> (Int) -> () : @B_i_set
#B.i!modify: (B) -> () -> () : @B_i_modify
#B.i!modify2: (B) -> () -> () : @B_i_modify2
#B.i!modify: (B) -> @yield_once () -> inout @yields Int : @B_i_modify
#B.i!modify2: (B) -> @yield_once () -> inout @yields Int : @B_i_modify2
}
sil @B_i_read2_default_override : $@yield_once_2 @convention(method) (@guaranteed B) -> @yields Int
sil @B_i_modify2_default_override : $@yield_once_2 @convention(method) (@guaranteed B) -> @yields @inout Int
// CHECK-LABEL: sil_default_override_table B {
// CHECK-NEXT: #B.i!read2: #B.i!read: (B) -> () -> () : @B_i_read2_default_override
// CHECK-NEXT: #B.i!modify2: #B.i!modify: (B) -> () -> () : @B_i_modify2_default_override
// CHECK-NEXT: #B.i!read2: #B.i!read: (B) -> @yield_once () -> @yields Int : @B_i_read2_default_override
// CHECK-NEXT: #B.i!modify2: #B.i!modify: (B) -> @yield_once () -> inout @yields Int : @B_i_modify2_default_override
// CHECK-NEXT: }
sil_default_override_table B {
#B.i!read2: #B.i!read: (B) -> () -> () : @B_i_read2_default_override
#B.i!modify2: #B.i!modify: (B) -> () -> () : @B_i_modify2_default_override
#B.i!read2: #B.i!read: (B) -> @yield_once () -> @yields Int : @B_i_read2_default_override
#B.i!modify2: #B.i!modify: (B) -> @yield_once () -> inout @yields Int : @B_i_modify2_default_override
}

View File

@@ -112,21 +112,21 @@ func testP1(_ p: some P) {
// CHECK: sil hidden [ossa] @$s25borrow_accessor_synthesis6testP2yyxzAA1PRzlF : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@inout τ_0_0) -> () {
// CHECK: bb0([[REG0:%.*]] : $*τ_0_0):
// CHECK: [[REG2:%.*]] = begin_access [modify] [unknown] [[REG0]]
// CHECK: [[REG3:%.*]] = witness_method $τ_0_0, #P.prop1!modify : <Self where Self : P> (inout Self) -> () -> () : $@yield_once @convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@inout τ_0_0) -> @yields @inout τ_0_0.Element
// CHECK: [[REG3:%.*]] = witness_method $τ_0_0, #P.prop1!modify : <Self where Self : P> (inout Self) -> @yield_once () -> inout @yields Self.Element : $@yield_once @convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@inout τ_0_0) -> @yields @inout τ_0_0.Element
// CHECK: ([[REG4]], [[REG5]]) = begin_apply [[REG3]]<τ_0_0>([[REG2]]) : $@yield_once @convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@inout τ_0_0) -> @yields @inout τ_0_0.Element
// CHECK: [[REG6:%.*]] = function_ref @$s25borrow_accessor_synthesis6mutateyyxzRi_zlF : $@convention(thin) <τ_0_0 where τ_0_0 : ~Copyable> (@inout τ_0_0) -> ()
// CHECK: [[REG7:%.*]] = apply [[REG6]]<(τ_0_0).Element>([[REG4]]) : $@convention(thin) <τ_0_0 where τ_0_0 : ~Copyable> (@inout τ_0_0) -> ()
// CHECK: [[REG8:%.*]] = end_apply [[REG5]] as $()
// CHECK: end_access [[REG2]]
// CHECK: [[REG10:%.*]] = begin_access [modify] [unknown] [[REG0]]
// CHECK: [[REG11:%.*]] = witness_method $τ_0_0, #P.prop2!modify : <Self where Self : P> (inout Self) -> () -> () : $@yield_once @convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@inout τ_0_0) -> @yields @inout τ_0_0.Element
// CHECK: [[REG11:%.*]] = witness_method $τ_0_0, #P.prop2!modify : <Self where Self : P> (inout Self) -> @yield_once () -> inout @yields Self.Element : $@yield_once @convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@inout τ_0_0) -> @yields @inout τ_0_0.Element
// CHECK: ([[REG12:%.*]], [[REG13:%.*]]) = begin_apply [[REG11]]<τ_0_0>([[REG10]]) : $@yield_once @convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@inout τ_0_0) -> @yields @inout τ_0_0.Element
// CHECK: [[REG14:%.*]] = function_ref @$s25borrow_accessor_synthesis6mutateyyxzRi_zlF : $@convention(thin) <τ_0_0 where τ_0_0 : ~Copyable> (@inout τ_0_0) -> ()
// CHECK: [[REG15:%.*]] = apply [[REG14]]<(τ_0_0).Element>([[REG12]]) : $@convention(thin) <τ_0_0 where τ_0_0 : ~Copyable> (@inout τ_0_0) -> ()
// CHECK: [[REG16:%.*]] = end_apply [[REG13]] as $()
// CHECK: end_access [[REG10]]
// CHECK: [[REG18:%.*]] = begin_access [modify] [unknown] [[REG0]]
// CHECK: [[REG19:%.*]] = witness_method $τ_0_0, #P.prop3!modify : <Self where Self : P> (inout Self) -> () -> () : $@yield_once @convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@inout τ_0_0) -> @yields @inout τ_0_0.Element
// CHECK: [[REG19:%.*]] = witness_method $τ_0_0, #P.prop3!modify : <Self where Self : P> (inout Self) -> @yield_once () -> inout @yields Self.Element : $@yield_once @convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@inout τ_0_0) -> @yields @inout τ_0_0.Element
// CHECK: ([[REG20:%.*]], [[REG21:%.*]]) = begin_apply [[REG19]]<τ_0_0>([[REG18]]) : $@yield_once @convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@inout τ_0_0) -> @yields @inout τ_0_0.Element
// CHECK: [[REG22:%.*]] = function_ref @$s25borrow_accessor_synthesis6mutateyyxzRi_zlF : $@convention(thin) <τ_0_0 where τ_0_0 : ~Copyable> (@inout τ_0_0) -> ()
// CHECK: [[REG23:%.*]] = apply [[REG22]]<(τ_0_0).Element>([[REG20]]) : $@convention(thin) <τ_0_0 where τ_0_0 : ~Copyable> (@inout τ_0_0) -> ()
@@ -188,19 +188,19 @@ func testP3(_ p: inout some P) {
// CHECK: sil hidden [ossa] @$s25borrow_accessor_synthesis8testNCP1yyxAA3NCPRzlF : $@convention(thin) <τ_0_0 where τ_0_0 : NCP> (@in_guaranteed τ_0_0) -> () {
// CHECK: bb0([[REG0:%.*]] : $*τ_0_0):
// CHECK: [[REG2:%.*]] = witness_method $τ_0_0, #NCP.prop1!read : <Self where Self : NCP, Self : ~Copyable> (Self) -> () -> () : $@yield_once @convention(witness_method: NCP) <τ_0_0 where τ_0_0 : NCP, τ_0_0 : ~Copyable> (@in_guaranteed τ_0_0) -> @yields @in_guaranteed τ_0_0.Element
// CHECK: [[REG2:%.*]] = witness_method $τ_0_0, #NCP.prop1!read : <Self where Self : NCP, Self : ~Copyable> (Self) -> @yield_once () -> @yields Self.Element : $@yield_once @convention(witness_method: NCP) <τ_0_0 where τ_0_0 : NCP, τ_0_0 : ~Copyable> (@in_guaranteed τ_0_0) -> @yields @in_guaranteed τ_0_0.Element
// CHECK: ([[REG3:%.*]], [[REG4:%.*]]) = begin_apply [[REG2]]<τ_0_0>([[REG0]]) : $@yield_once @convention(witness_method: NCP) <τ_0_0 where τ_0_0 : NCP, τ_0_0 : ~Copyable> (@in_guaranteed τ_0_0) -> @yields @in_guaranteed τ_0_0.Element
// CHECK: [[REG5:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG3]]
// CHECK: [[REG6:%.*]] = function_ref @$s25borrow_accessor_synthesis3useyyxRi_zlF : $@convention(thin) <τ_0_0 where τ_0_0 : ~Copyable> (@in_guaranteed τ_0_0) -> ()
// CHECK: [[REG7:%.*]] = apply [[REG6]]<(τ_0_0).Element>([[REG5]]) : $@convention(thin) <τ_0_0 where τ_0_0 : ~Copyable> (@in_guaranteed τ_0_0) -> ()
// CHECK: [[REG8:%.*]] = end_apply [[REG4]] as $()
// CHECK: [[REG9:%.*]] = witness_method $τ_0_0, #NCP.prop2!read : <Self where Self : NCP, Self : ~Copyable> (Self) -> () -> () : $@yield_once @convention(witness_method: NCP) <τ_0_0 where τ_0_0 : NCP, τ_0_0 : ~Copyable> (@in_guaranteed τ_0_0) -> @yields @in_guaranteed τ_0_0.Element
// CHECK: [[REG9:%.*]] = witness_method $τ_0_0, #NCP.prop2!read : <Self where Self : NCP, Self : ~Copyable> (Self) -> @yield_once () -> @yields Self.Element : $@yield_once @convention(witness_method: NCP) <τ_0_0 where τ_0_0 : NCP, τ_0_0 : ~Copyable> (@in_guaranteed τ_0_0) -> @yields @in_guaranteed τ_0_0.Element
// CHECK: ([[REG10:%.*]], [[REG11:%.*]]) = begin_apply [[REG9]]<τ_0_0>([[REG0]]) : $@yield_once @convention(witness_method: NCP) <τ_0_0 where τ_0_0 : NCP, τ_0_0 : ~Copyable> (@in_guaranteed τ_0_0) -> @yields @in_guaranteed τ_0_0.Element
// CHECK: [[REG12:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG10]]
// CHECK: [[REG13:%.*]] = function_ref @$s25borrow_accessor_synthesis3useyyxRi_zlF : $@convention(thin) <τ_0_0 where τ_0_0 : ~Copyable> (@in_guaranteed τ_0_0) -> ()
// CHECK: [[REG14:%.*]] = apply [[REG13]]<(τ_0_0).Element>([[REG12]]) : $@convention(thin) <τ_0_0 where τ_0_0 : ~Copyable> (@in_guaranteed τ_0_0) -> ()
// CHECK: [[REG15:%.*]] = end_apply [[REG11]] as $()
// CHECK: [[REG16:%.*]] = witness_method $τ_0_0, #NCP.prop3!read : <Self where Self : NCP, Self : ~Copyable> (Self) -> () -> () : $@yield_once @convention(witness_method: NCP) <τ_0_0 where τ_0_0 : NCP, τ_0_0 : ~Copyable> (@in_guaranteed τ_0_0) -> @yields @in_guaranteed τ_0_0.Element
// CHECK: [[REG16:%.*]] = witness_method $τ_0_0, #NCP.prop3!read : <Self where Self : NCP, Self : ~Copyable> (Self) -> @yield_once () -> @yields Self.Element : $@yield_once @convention(witness_method: NCP) <τ_0_0 where τ_0_0 : NCP, τ_0_0 : ~Copyable> (@in_guaranteed τ_0_0) -> @yields @in_guaranteed τ_0_0.Element
// CHECK: [[REG19:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG17]]
// CHECK: [[REG20:%.*]] = function_ref @$s25borrow_accessor_synthesis3useyyxRi_zlF : $@convention(thin) <τ_0_0 where τ_0_0 : ~Copyable> (@in_guaranteed τ_0_0) -> ()
// CHECK: [[REG21:%.*]] = apply [[REG20]]<(τ_0_0).Element>([[REG19]]) : $@convention(thin) <τ_0_0 where τ_0_0 : ~Copyable> (@in_guaranteed τ_0_0) -> ()
@@ -215,7 +215,7 @@ func testNCP1(_ p: some NCP) {
// CHECK: sil hidden [ossa] @$s25borrow_accessor_synthesis8testNCP2yyxzAA3NCPRzlF : $@convention(thin) <τ_0_0 where τ_0_0 : NCP> (@inout τ_0_0) -> () {
// CHECK: bb0([[REG0:%.*]] : $*τ_0_0):
// CHECK: [[REG2:%.*]] = begin_access [modify] [unknown] [[REG0]]
// CHECK: [[REG3:%.*]] = witness_method $τ_0_0, #NCP.prop1!modify : <Self where Self : NCP, Self : ~Copyable> (inout Self) -> () -> () : $@yield_once @convention(witness_method: NCP) <τ_0_0 where τ_0_0 : NCP, τ_0_0 : ~Copyable> (@inout τ_0_0) -> @yields @inout τ_0_0.Element
// CHECK: [[REG3:%.*]] = witness_method $τ_0_0, #NCP.prop1!modify : <Self where Self : NCP, Self : ~Copyable> (inout Self) -> @yield_once () -> inout @yields Self.Element : $@yield_once @convention(witness_method: NCP) <τ_0_0 where τ_0_0 : NCP, τ_0_0 : ~Copyable> (@inout τ_0_0) -> @yields @inout τ_0_0.Element
// CHECK: ([[REG4:%.*]], [[REG5:%.*]]) = begin_apply [[REG3]]<τ_0_0>([[REG2]]) : $@yield_once @convention(witness_method: NCP) <τ_0_0 where τ_0_0 : NCP, τ_0_0 : ~Copyable> (@inout τ_0_0) -> @yields @inout τ_0_0.Element
// CHECK: [[REG6:%.*]] = mark_unresolved_non_copyable_value [consumable_and_assignable] [[REG4]]
// CHECK: [[REG7:%.*]] = function_ref @$s25borrow_accessor_synthesis6mutateyyxzRi_zlF : $@convention(thin) <τ_0_0 where τ_0_0 : ~Copyable> (@inout τ_0_0) -> ()
@@ -223,7 +223,7 @@ func testNCP1(_ p: some NCP) {
// CHECK: [[REG9:%.*]] = end_apply [[REG5]] as $()
// CHECK: end_access [[REG2]]
// CHECK: [[REG11:%.*]] = begin_access [modify] [unknown] [[REG0]]
// CHECK: [[REG12:%.*]] = witness_method $τ_0_0, #NCP.prop2!modify : <Self where Self : NCP, Self : ~Copyable> (inout Self) -> () -> () : $@yield_once @convention(witness_method: NCP) <τ_0_0 where τ_0_0 : NCP, τ_0_0 : ~Copyable> (@inout τ_0_0) -> @yields @inout τ_0_0.Element
// CHECK: [[REG12:%.*]] = witness_method $τ_0_0, #NCP.prop2!modify : <Self where Self : NCP, Self : ~Copyable> (inout Self) -> @yield_once () -> inout @yields Self.Element : $@yield_once @convention(witness_method: NCP) <τ_0_0 where τ_0_0 : NCP, τ_0_0 : ~Copyable> (@inout τ_0_0) -> @yields @inout τ_0_0.Element
// CHECK: ([[REG13:%.*]], [[REG14:%.*]]) = begin_apply [[REG12]]<τ_0_0>([[REG11]]) : $@yield_once @convention(witness_method: NCP) <τ_0_0 where τ_0_0 : NCP, τ_0_0 : ~Copyable> (@inout τ_0_0) -> @yields @inout τ_0_0.Element
// CHECK: [[REG15:%.*]] = mark_unresolved_non_copyable_value [consumable_and_assignable] [[REG13]]
// CHECK: [[REG16:%.*]] = function_ref @$s25borrow_accessor_synthesis6mutateyyxzRi_zlF : $@convention(thin) <τ_0_0 where τ_0_0 : ~Copyable> (@inout τ_0_0) -> ()
@@ -231,7 +231,7 @@ func testNCP1(_ p: some NCP) {
// CHECK: [[REG18:%.*]] = end_apply [[REG14]] as $()
// CHECK: end_access [[REG11]]
// CHECK: [[REG20:%.*]] = begin_access [modify] [unknown] [[REG0]]
// CHECK: [[REG21:%.*]] = witness_method $τ_0_0, #NCP.prop3!modify : <Self where Self : NCP, Self : ~Copyable> (inout Self) -> () -> () : $@yield_once @convention(witness_method: NCP) <τ_0_0 where τ_0_0 : NCP, τ_0_0 : ~Copyable> (@inout τ_0_0) -> @yields @inout τ_0_0.Element
// CHECK: [[REG21:%.*]] = witness_method $τ_0_0, #NCP.prop3!modify : <Self where Self : NCP, Self : ~Copyable> (inout Self) -> @yield_once () -> inout @yields Self.Element : $@yield_once @convention(witness_method: NCP) <τ_0_0 where τ_0_0 : NCP, τ_0_0 : ~Copyable> (@inout τ_0_0) -> @yields @inout τ_0_0.Element
// CHECK: ([[REG22:%.*]], [[REG23:%.*]]) = begin_apply [[REG21]]<τ_0_0>([[REG20]]) : $@yield_once @convention(witness_method: NCP) <τ_0_0 where τ_0_0 : NCP, τ_0_0 : ~Copyable> (@inout τ_0_0) -> @yields @inout τ_0_0.Element
// CHECK: [[REG24:%.*]] = mark_unresolved_non_copyable_value [consumable_and_assignable] [[REG22]]
// CHECK: [[REG25:%.*]] = function_ref @$s25borrow_accessor_synthesis6mutateyyxzRi_zlF : $@convention(thin) <τ_0_0 where τ_0_0 : ~Copyable> (@inout τ_0_0) -> ()
@@ -464,7 +464,7 @@ public struct RigidWrapper<T: ~Copyable>: Container & ~Copyable {
// CHECK: sil hidden [ossa] @$s25borrow_accessor_synthesis13testContaineryyx_SitAA0E0RzlF : $@convention(thin) <T where T : Container> (@in_guaranteed T, Int) -> () {
// CHECK: bb0([[REG0:%.*]] : $*T, [[REG1:%.*]] : $Int):
// CHECK: [[REG4:%.*]] = witness_method $T, #Container.subscript!read : <Self where Self : Container, Self : ~Copyable> (Self) -> (Int) -> () : $@yield_once @convention(witness_method: Container) <τ_0_0 where τ_0_0 : Container, τ_0_0 : ~Copyable> (Int, @in_guaranteed τ_0_0) -> @yields @in_guaranteed τ_0_0.Element
// CHECK: [[REG4:%.*]] = witness_method $T, #Container.subscript!read : <Self where Self : Container, Self : ~Copyable> (Self) -> @yield_once (Int) -> @yields Self.Element : $@yield_once @convention(witness_method: Container) <τ_0_0 where τ_0_0 : Container, τ_0_0 : ~Copyable> (Int, @in_guaranteed τ_0_0) -> @yields @in_guaranteed τ_0_0.Element
// CHECK: ([[REG5:%.*]], [[REG6:%.*]]) = begin_apply [[REG4]]<T>([[REG1]], [[REG0]]) : $@yield_once @convention(witness_method: Container) <τ_0_0 where τ_0_0 : Container, τ_0_0 : ~Copyable> (Int, @in_guaranteed τ_0_0) -> @yields @in_guaranteed τ_0_0.Element
// CHECK: [[REG7:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG5]]
// CHECK: [[REG8:%.*]] = function_ref @$s25borrow_accessor_synthesis3useyyxRi_zlF : $@convention(thin) <τ_0_0 where τ_0_0 : ~Copyable> (@in_guaranteed τ_0_0) -> ()

View File

@@ -38,7 +38,7 @@ open class OpenBase<T> {
// CHECK-SAME: [[SELF:%[^,]+]] :
// CHECK-SAME: ):
// CHECK: [[ORIGINAL:%[^,]+]] = class_method [[SELF]], #OpenBase.openField!read
// CHECK-SAME: <T> (OpenBase<T>) -> () -> ()
// CHECK-SAME: <T> (OpenBase<T>) -> @yield_once () -> @yields T
// CHECK-SAME: $@yield_once @convention(method) <τ_0_0> (@guaranteed OpenBase<τ_0_0>) -> @yields @in_guaranteed τ_0_0
// CHECK: ([[ADDR:%[^,]+]], [[TOKEN:%[^,]+]]) = begin_apply [[ORIGINAL]]<τ_0_0>([[SELF]])
// CHECK: yield [[ADDR]]
@@ -69,7 +69,7 @@ open class OpenBase<T> {
// CHECK-SAME: [[SELF:%[^,]+]] :
// CHECK-SAME: ):
// CHECK: [[ORIGINAL:%[^,]+]] = class_method [[SELF]], #OpenBase.openField!modify
// CHECK: <T> (OpenBase<T>) -> () -> ()
// CHECK: <T> (OpenBase<T>) -> @yield_once () -> inout @yields T
// CHECK: $@yield_once @convention(method) <τ_0_0> (@guaranteed OpenBase<τ_0_0>) -> @yields @inout τ_0_0
// CHECK: ([[ADDR:%[^,]+]], [[TOKEN:%[^,]+]]) = begin_apply [[ORIGINAL]]<τ_0_0>([[SELF]])
// CHECK: yield [[ADDR]]
@@ -107,7 +107,7 @@ open class OpenBase<T> {
// CHECK-SAME: ):
// CHECK: [[ORIGINAL:%[^,]+]] = class_method [[SELF]]
// CHECK: #OpenBase.subscript!read
// CHECK: <T><U> (OpenBase<T>) -> (U, Open.Type) -> ()
// CHECK: <T><U> (OpenBase<T>) -> @yield_once (U, Open.Type) -> @yields T
// CHECK: $@yield_once @convention(method) <τ_0_0><τ_1_0> (@in_guaranteed τ_1_0, @thin Open.Type, @guaranteed OpenBase<τ_0_0>) -> @yields @in_guaranteed τ_0_0
// CHECK: ([[ADDR:%[^,]+]], [[TOKEN:%[^,]+]]) = begin_apply [[ORIGINAL]]<τ_0_0, τ_1_0>([[KEY]], [[OPEN_TY]], [[SELF]])
// CHECK: yield [[ADDR]]
@@ -143,7 +143,7 @@ open class OpenBase<T> {
// CHECK-SAME: ):
// CHECK: [[ORIGINAL:%[^,]+]] = class_method [[SELF]]
// CHECK-SAME: #OpenBase.subscript!modify
// CHECK-SAME: <T><U> (OpenBase<T>) -> (U, Open.Type) -> ()
// CHECK-SAME: <T><U> (OpenBase<T>) -> @yield_once (U, Open.Type) -> inout @yields T
// CHECK-SAME: $@yield_once @convention(method) <τ_0_0><τ_1_0> (@in_guaranteed τ_1_0, @thin Open.Type, @guaranteed OpenBase<τ_0_0>) -> @yields @inout τ_0_0
// CHECK: ([[ADDR:%[^,]+]], [[TOKEN:%[^,]+]]) = begin_apply [[ORIGINAL]]<τ_0_0, τ_1_0>([[KEY]], [[OPEN_TY]], [[SELF]])
// CHECK: yield [[ADDR]]
@@ -300,24 +300,24 @@ class InternalBase<T> {
// CHECK-LABEL: sil_default_override_table OpenBase {
// CHECK-NEXT: #OpenBase.openField!read2
// CHECK-SAME: #OpenBase.openField!read
// CHECK-SAME: <T> (OpenBase<T>) -> () -> ()
// CHECK-SAME: <T> (OpenBase<T>) -> @yield_once () -> @yields T
// CHECK-SAME: @$s16default_override8OpenBaseC9openFieldxvyTwd
// CHECK-NEXT: #OpenBase.openField!modify2
// CHECK-SAME: #OpenBase.openField!modify
// CHECK-SAME: <T> (OpenBase<T>) -> () -> ()
// CHECK-SAME: <T> (OpenBase<T>) -> @yield_once () -> inout @yields T
// CHECK-SAME: @$s16default_override8OpenBaseC9openFieldxvxTwd
// CHECK-NEXT: #OpenBase.subscript!read2
// CHECK-SAME: #OpenBase.subscript!read
// CHECK-SAME: <T><U> (OpenBase<T>) -> (U, Open.Type) -> ()
// CHECK-SAME: <T><U> (OpenBase<T>) -> @yield_once (U, Open.Type) -> @yields T
// CHECK-SAME: @$s16default_override8OpenBaseCyxqd___AA0C0OmtcluiyTwd
// CHECK-NEXT: #OpenBase.subscript!modify2
// CHECK-SAME: #OpenBase.subscript!modify
// CHECK-SAME: <T><U> (OpenBase<T>) -> (U, Open.Type) -> ()
// CHECK-SAME: <T><U> (OpenBase<T>) -> @yield_once (U, Open.Type) -> inout @yields T
// CHECK-SAME: @$s16default_override8OpenBaseCyxqd___AA0C0OmtcluixTwd
// CHECK-NOT: #OpenBase.publicField!read2
// CHECK-NOT: #OpenBase.publicField!modify2
// CHECK-NOT: #OpenBase.subscript!read2: #OpenBase.subscript!read: <T><U> (OpenBase<T>) -> (U, Public.Type) -> ()
// CHECK-NOT: #OpenBase.subscript!modify2: #OpenBase.subscript!modify: <T><U> (OpenBase<T>) -> (U, Public.Type) -> ()
// CHECK-NOT: #OpenBase.subscript!read2: #OpenBase.subscript!read: <T><U> (OpenBase<T>) -> @yield_once (U, Public.Type) -> @yields T
// CHECK-NOT: #OpenBase.subscript!modify2: #OpenBase.subscript!modify: <T><U> (OpenBase<T>) -> @yield_once (U, Public.Type) -> inout @yields T
// CHECK-NEXT: }
// CHECK-NOT: sil_default_override_table PublicBase {

View File

@@ -207,8 +207,8 @@ func test_subscript_computed_property_and_mutating_access(u: User) {
// CHECK-NEXT: {{.*}} = apply [[SUBSCRIPT_GETTER]]<String, Any, String>({{.*}}, [[BORROWED_COPY]])
_ = u.dict[entry: ""]
// CHECK: [[DICT_GETTER:%.*]] = class_method %0, #User.dict!modify : (User) -> () -> (), $@yield_once @convention(method) (@guaranteed User) -> @yields @inout Dictionary<String, any Sendable>
// CHECK-NEXT: ([[DICT_ADDR:%.*]], {{.*}}) = begin_apply [[DICT_GETTER]]({{.*}}) : $@yield_once @convention(method) (@guaranteed User) -> @yields @inout Dictionary<String, any Sendable>
// CHECK: [[DICT_MODIFY:%.*]] = class_method %0, #User.dict!modify : (User) -> @yield_once () -> inout @yields [String : any Sendable], $@yield_once @convention(method) (@guaranteed User) -> @yields @inout Dictionary<String, any Sendable>
// CHECK-NEXT: ([[DICT_ADDR:%.*]], {{.*}}) = begin_apply [[DICT_MODIFY]]({{.*}}) : $@yield_once @convention(method) (@guaranteed User) -> @yields @inout Dictionary<String, any Sendable>
// CHECK-NEXT: [[ANY_DICT:%.*]] = alloc_stack $Dictionary<String, Any>
// CHECK-NEXT: [[LOADED_DICT:%.*]] = load [copy] [[DICT_ADDR]]
// CHECK-NEXT: [[ANY_LOADED_DICT:%.*]] = unchecked_bitwise_cast [[LOADED_DICT]] to $Dictionary<String, Any>
@@ -231,8 +231,8 @@ func test_subscript_computed_property_and_mutating_access(u: User) {
// CHECK-NEXT: {{.*}} = apply [[GETTER]]([[ANY_DICT]]) : $@convention(method) (@guaranteed Dictionary<String, Any>) -> Optional<Int>
_ = u.dict.test
// CHECK: [[DICT_GETTER:%.*]] = class_method %0, #User.dict!modify : (User) -> () -> (), $@yield_once @convention(method) (@guaranteed User) -> @yields @inout Dictionary<String, any Sendable>
// CHECK-NEXT: ([[DICT:%.*]], {{.*}}) = begin_apply [[DICT_GETTER]]({{.*}}) : $@yield_once @convention(method) (@guaranteed User) -> @yields @inout Dictionary<String, any Sendable>
// CHECK: [[DICT_MODIFY:%.*]] = class_method %0, #User.dict!modify : (User) -> @yield_once () -> inout @yields [String : any Sendable], $@yield_once @convention(method) (@guaranteed User) -> @yields @inout Dictionary<String, any Sendable>
// CHECK-NEXT: ([[DICT:%.*]], {{.*}}) = begin_apply [[DICT_MODIFY]]({{.*}}) : $@yield_once @convention(method) (@guaranteed User) -> @yields @inout Dictionary<String, any Sendable>
// CHECK-NEXT: [[ANY_DICT:%.*]] = alloc_stack $Dictionary<String, Any>
// CHECK-NEXT: [[LOADED_DICT:%.*]] = load [copy] [[DICT]]
// CHECK-NEXT: [[CASTED_DICT:%.*]] = unchecked_bitwise_cast [[LOADED_DICT]] to $Dictionary<String, Any>
@@ -246,8 +246,8 @@ func test_subscript_computed_property_and_mutating_access(u: User) {
// CHECK-NEXT: assign [[COPIED_SENDABLE_DICT]] to [[DICT]]
u.dict.test = 42
// CHECK: [[DICT_GETTER:%.*]] = class_method %0, #User.dict!modify : (User) -> () -> (), $@yield_once @convention(method) (@guaranteed User) -> @yields @inout Dictionary<String, any Sendable>
// CHECK-NEXT: ([[DICT:%.*]], {{.*}}) = begin_apply [[DICT_GETTER:%.*]](%0) : $@yield_once @convention(method) (@guaranteed User) -> @yields @inout Dictionary<String, any Sendable>
// CHECK: [[DICT_MODIFY:%.*]] = class_method %0, #User.dict!modify : (User) -> @yield_once () -> inout @yields [String : any Sendable], $@yield_once @convention(method) (@guaranteed User) -> @yields @inout Dictionary<String, any Sendable>
// CHECK-NEXT: ([[DICT:%.*]], {{.*}}) = begin_apply [[DICT_MODIFY:%.*]](%0) : $@yield_once @convention(method) (@guaranteed User) -> @yields @inout Dictionary<String, any Sendable>
// CHECK-NEXT: [[ANY_DICT:%.*]] = alloc_stack $Dictionary<String, Any>
// CHECK-NEXT: [[LOADED_DICT:%.*]] = load [copy] [[DICT]]
// CHECK-NEXT: [[CASTED_DICT:%.*]] = unchecked_bitwise_cast [[LOADED_DICT]] to $Dictionary<String, Any>

View File

@@ -29,7 +29,7 @@ sil [ossa] @utilize_begin_apply : $@convention(thin) () -> () {
bb0:
%derived = alloc_ref $Derived
%base = upcast %derived : $Derived to $Base
%reader = class_method %base : $Base, #Base.x!read2 : (Base) -> () -> (), $@yield_once_2 @convention(method) (@guaranteed Base) -> @yields Int
%reader = class_method %base : $Base, #Base.x!read2 : (Base) -> @yield_once () -> @yields Int, $@yield_once_2 @convention(method) (@guaranteed Base) -> @yields Int
(%value, %token, %allocation) = begin_apply %reader(%base) : $@yield_once_2 @convention(method) (@guaranteed Base) -> @yields Int
end_apply %token as $()
dealloc_stack %allocation : $*Builtin.SILToken

View File

@@ -30,17 +30,17 @@
// CHECK-INPKG: sil_vtable Pub {
// CHECK-INPKG: #Pub.pubVar!getter: (Pub) -> () -> Int : @$s3Lib3PubC6pubVarSivg // Pub.pubVar.getter
// CHECK-INPKG: #Pub.pubVar!setter: (Pub) -> (Int) -> () : @$s3Lib3PubC6pubVarSivs // Pub.pubVar.setter
// CHECK-INPKG: #Pub.pubVar!modify: (Pub) -> () -> () : @$s3Lib3PubC6pubVarSivM // Pub.pubVar.modify
// CHECK-INPKG: #Pub.pubVar!modify: (Pub) -> @yield_once () -> inout @yields Int : @$s3Lib3PubC6pubVarSivM // Pub.pubVar.modify
// CHECK-INPKG: #Pub.pkgVar!getter: (Pub) -> () -> Int : @$s3Lib3PubC6pkgVarSivg // Pub.pkgVar.getter
// CHECK-INPKG: #Pub.pkgVar!setter: (Pub) -> (Int) -> () : @$s3Lib3PubC6pkgVarSivs // Pub.pkgVar.setter
// CHECK-INPKG: #Pub.pkgVar!modify: (Pub) -> () -> () : @$s3Lib3PubC6pkgVarSivM // Pub.pkgVar.modify
// CHECK-INPKG: #Pub.pkgVar!modify: (Pub) -> @yield_once () -> inout @yields Int : @$s3Lib3PubC6pkgVarSivM // Pub.pkgVar.modify
// CHECK-INPKG: #Pub.init!allocator: (Pub.Type) -> (Int) -> Pub : @$s3Lib3PubCyACSicfC // Pub.__allocating_init(_:)
// CHECK-INPKG: #Pub.deinit!deallocator: @$s3Lib3PubCfD // Pub.__deallocating_deinit
// CHECK-INPKG: sil_witness_table public_external Pub: PubProto module Lib {
// CHECK-INPKG: method #PubProto.pubVar!getter: <Self where Self : PubProto> (Self) -> () -> Int : @$s3Lib3PubCAA0B5ProtoA2aDP6pubVarSivgTW // protocol witness for PubProto.pubVar.getter in conformance Pub
// CHECK-INPKG: method #PubProto.pubVar!setter: <Self where Self : PubProto> (inout Self) -> (Int) -> () : @$s3Lib3PubCAA0B5ProtoA2aDP6pubVarSivsTW // protocol witness for PubProto.pubVar.setter in conformance Pub
// CHECK-INPKG: method #PubProto.pubVar!modify: <Self where Self : PubProto> (inout Self) -> () -> () : @$s3Lib3PubCAA0B5ProtoA2aDP6pubVarSivMTW // protocol witness for PubProto.pubVar.modify in conformance Pub
// CHECK-INPKG: method #PubProto.pubVar!modify: <Self where Self : PubProto> (inout Self) -> @yield_once () -> inout @yields Int : @$s3Lib3PubCAA0B5ProtoA2aDP6pubVarSivMTW // protocol witness for PubProto.pubVar.modify in conformance Pub
/// Test 2: They should NOT be deserialized into Client as Lib and Client are NOT in the same package;
@@ -78,17 +78,17 @@
// CHECK-LIB: sil_vtable [serialized_for_package] Pub {
// CHECK-LIB: #Pub.pubVar!getter: (Pub) -> () -> Int : @$s3Lib3PubC6pubVarSivg // Pub.pubVar.getter
// CHECK-LIB: #Pub.pubVar!setter: (Pub) -> (Int) -> () : @$s3Lib3PubC6pubVarSivs // Pub.pubVar.setter
// CHECK-LIB: #Pub.pubVar!modify: (Pub) -> () -> () : @$s3Lib3PubC6pubVarSivM // Pub.pubVar.modify
// CHECK-LIB: #Pub.pubVar!modify: (Pub) -> @yield_once () -> inout @yields Int : @$s3Lib3PubC6pubVarSivM // Pub.pubVar.modify
// CHECK-LIB: #Pub.pkgVar!getter: (Pub) -> () -> Int : @$s3Lib3PubC6pkgVarSivg // Pub.pkgVar.getter
// CHECK-LIB: #Pub.pkgVar!setter: (Pub) -> (Int) -> () : @$s3Lib3PubC6pkgVarSivs // Pub.pkgVar.setter
// CHECK-LIB: #Pub.pkgVar!modify: (Pub) -> () -> () : @$s3Lib3PubC6pkgVarSivM // Pub.pkgVar.modify
// CHECK-LIB: #Pub.pkgVar!modify: (Pub) -> @yield_once () -> inout @yields Int : @$s3Lib3PubC6pkgVarSivM // Pub.pkgVar.modify
// CHECK-LIB: #Pub.init!allocator: (Pub.Type) -> (Int) -> Pub : @$s3Lib3PubCyACSicfC // Pub.__allocating_init(_:)
// CHECK-LIB: #Pub.deinit!deallocator: @$s3Lib3PubCfD // Pub.__deallocating_deinit
// CHECK-LIB: sil_witness_table [serialized_for_package] Pub: PubProto module Lib {
// CHECK-LIB: method #PubProto.pubVar!getter: <Self where Self : PubProto> (Self) -> () -> Int : @$s3Lib3PubCAA0B5ProtoA2aDP6pubVarSivgTW // protocol witness for PubProto.pubVar.getter in conformance Pub
// CHECK-LIB: method #PubProto.pubVar!setter: <Self where Self : PubProto> (inout Self) -> (Int) -> () : @$s3Lib3PubCAA0B5ProtoA2aDP6pubVarSivsTW // protocol witness for PubProto.pubVar.setter in conformance Pub
// CHECK-LIB: method #PubProto.pubVar!modify: <Self where Self : PubProto> (inout Self) -> () -> () : @$s3Lib3PubCAA0B5ProtoA2aDP6pubVarSivMTW // protocol witness for PubProto.pubVar.modify in conformance Pub
// CHECK-LIB: method #PubProto.pubVar!modify: <Self where Self : PubProto> (inout Self) -> @yield_once () -> inout @yields Int : @$s3Lib3PubCAA0B5ProtoA2aDP6pubVarSivMTW // protocol witness for PubProto.pubVar.modify in conformance Pub
//--- Lib.swift

View File

@@ -53,7 +53,7 @@ bb0(%0 : $*Optional<τ_0_0.Element>, %1 : $*IndexingIterator<τ_0_0>):
copy_addr %3 to [init] %22 : $*τ_0_0.Index
%24 = alloc_stack $τ_0_0
copy_addr [take] %20 to [init] %24 : $*τ_0_0
%26 = witness_method $τ_0_0, #Collection.subscript!read : <Self where Self : Collection> (Self) -> (Self.Index) -> () : $@yield_once @convention(witness_method: Collection) <τ_0_0 where τ_0_0 : Collection> (@in_guaranteed τ_0_0.Index, @in_guaranteed τ_0_0) -> @yields @in_guaranteed τ_0_0.Element
%26 = witness_method $τ_0_0, #Collection.subscript!read : <Self where Self : Collection> (Self) -> @yield_once (Self.Index) -> @yields Self.Element : $@yield_once @convention(witness_method: Collection) <τ_0_0 where τ_0_0 : Collection> (@in_guaranteed τ_0_0.Index, @in_guaranteed τ_0_0) -> @yields @in_guaranteed τ_0_0.Element
// The specialized begin apply %26<Test> has a result type of t_0_0.Element
// which works out to be an opaque result type whose underlying type is Int64.

View File

@@ -52,7 +52,7 @@ bb0(%0 : $*Optional<τ_0_0.Element>, %1 : $*IndexingIterator<τ_0_0>):
copy_addr %3 to [init] %22 : $*τ_0_0.Index
%24 = alloc_stack $τ_0_0
copy_addr [take] %20 to [init] %24 : $*τ_0_0
%26 = witness_method $τ_0_0, #Collection.subscript!read : <Self where Self : Collection> (Self) -> (Self.Index) -> () : $@yield_once @convention(witness_method: Collection) <τ_0_0 where τ_0_0 : Collection> (@in_guaranteed τ_0_0.Index, @in_guaranteed τ_0_0) -> @yields @in_guaranteed τ_0_0.Element
%26 = witness_method $τ_0_0, #Collection.subscript!read : <Self where Self : Collection> (Self) -> @yield_once (Self.Index) -> @yields Self.Element : $@yield_once @convention(witness_method: Collection) <τ_0_0 where τ_0_0 : Collection> (@in_guaranteed τ_0_0.Index, @in_guaranteed τ_0_0) -> @yields @in_guaranteed τ_0_0.Element
// The specialized begin apply %26<Test> has a result type of t_0_0.Element
// which works out to be an opaque result type whose underlying type is Int64.

View File

@@ -46,7 +46,7 @@ public func bar(t: T2) -> MyClass<T2> {
// CHECK-SIL: sil_vtable $MyClass<T1> {
// CHECK-SIL: #MyClass.t!getter: <T> (MyClass<T>) -> () -> T : @$e4main7MyClassC1txvgAA2T1V_Tg5 // specialized MyClass.t.getter
// CHECK-SIL: #MyClass.t!setter: <T> (MyClass<T>) -> (T) -> () : @$e4main7MyClassC1txvsAA2T1V_Tg5 // specialized MyClass.t.setter
// CHECK-SIL: #MyClass.t!modify: <T> (MyClass<T>) -> () -> () : @$e4main7MyClassC1txvMAA2T1V_Tg5 // specialized MyClass.t.modify
// CHECK-SIL: #MyClass.t!modify: <T> (MyClass<T>) -> @yield_once () -> inout @yields T : @$e4main7MyClassC1txvMAA2T1V_Tg5 // specialized MyClass.t.modify
// CHECK-SIL: #MyClass.init!allocator: <T> (MyClass<T>.Type) -> (T) -> MyClass<T> : @$e4main7MyClassC1tACyxGx_tcfCAA2T1V_Tg5 // specialized MyClass.__allocating_init(t:)
// CHECK-SIL: #MyClass.deinit!deallocator: @$e4main7MyClassCfDAA2T1V_Tg5 // specialized MyClass.__deallocating_deinit
// CHECK-SIL: }