Skip to content

Commit 9da796c

Browse files
committed
Unbreak tests after read / modify accessors added
1 parent 679c670 commit 9da796c

8 files changed

+20
-15
lines changed

lib/Sema/TypeCheckStmt.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1109,8 +1109,14 @@ class StmtChecker : public StmtVisitor<StmtChecker, Stmt*> {
11091109

11101110
SmallVector<AnyFunctionType::Yield, 4> buffer;
11111111
auto TheFunc = AnyFunctionRef::fromDeclContext(DC);
1112-
auto yieldResults = TheFunc->getBodyYieldResults(buffer);
1112+
// Checking yields requires proper interface type. If decl is invalid, then
1113+
// we already emitted diagnostics elsewhere.
1114+
if (auto *AFD = TheFunc->getAbstractFunctionDecl()) {
1115+
if (AFD->isInvalid())
1116+
return YS;
1117+
}
11131118

1119+
auto yieldResults = TheFunc->getBodyYieldResults(buffer);
11141120
auto yieldExprs = YS->getMutableYields();
11151121
if (yieldExprs.size() != yieldResults.size()) {
11161122
getASTContext().Diags.diagnose(YS->getYieldLoc(), diag::bad_yield_count,

lib/Sema/TypeCheckStorage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2523,7 +2523,7 @@ createCoroutineAccessorPrototype(AbstractStorageDecl *storage,
25232523

25242524
// Coroutine accessors yields storage value types
25252525
const Type retTy = YieldResultType::get(storage->getValueInterfaceType(),
2526-
kind == AccessorKind::Modify);
2526+
isYieldingMutableAccessor(kind));
25272527

25282528
auto *accessor = AccessorDecl::create(
25292529
ctx, loc, /*AccessorKeywordLoc=*/SourceLoc(), kind, storage,

test/Parse/coroutine_accessors_ambiguity.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ func read<T>(_ c : () -> T) -> T { c() }
1717
// disabled: ok!
1818
var im : Int {
1919
modify { // expected-enabled-error{{variable with a 'modify' accessor must also have a getter, addressor, or 'read' accessor}}
20-
1 // expected-enabled-warning{{integer literal is unused}}
20+
1 // expected-enabled-error{{unexpected non-void return value in void function}}
2121
}
2222
}
2323

2424
// enabled: ok
2525
// disabled: ok!
2626
var ir : Int {
2727
read {
28-
1 // expected-enabled-warning{{integer literal is unused}}
28+
1 // expected-enabled-error{{unexpected non-void return value in void function}}
2929
}
3030
}

test/SILOptimizer/access_marker_verify.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -787,8 +787,7 @@ class C : Abstractable {
787787
// CHECK-NEXT: [[THUNKED_NEW_FN:%.*]] = partial_apply [callee_guaranteed] [[THUNK]]([[NEW_FN_CONV]])
788788
// CHECK-NEXT: store [[THUNKED_NEW_FN]] to [init] [[ADDR]] :
789789
// CHECK-NEXT: dealloc_stack [[TEMP]]
790-
// CHECK-NEXT: end_apply [[TOKEN]]
791-
// CHECK-NEXT: [[TUPLE:%.*]] = tuple ()
790+
// CHECK-NEXT: [[TUPLE:%.*]] = end_apply [[TOKEN]]
792791
// CHECK-NEXT: end_borrow [[SELF]] : $C
793792
// CHECK-NEXT: return [[TUPLE]]
794793

test/SILOptimizer/devirtualize_coroutine_accessors.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ sil [ossa] @utilize_begin_apply : $@convention(thin) () -> () {
2828
bb0:
2929
%derived = alloc_ref $Derived
3030
%base = upcast %derived : $Derived to $Base
31-
%reader = class_method %base : $Base, #Base.x!read2 : (Base) -> () -> (), $@yield_once_2 @convention(method) (@guaranteed Base) -> @yields Int
31+
%reader = class_method %base : $Base, #Base.x!read2 : (Base) -> @yield_once () -> @yields Int, $@yield_once_2 @convention(method) (@guaranteed Base) -> @yields Int
3232
(%value, %token, %allocation) = begin_apply %reader(%base) : $@yield_once_2 @convention(method) (@guaranteed Base) -> @yields Int
3333
end_apply %token as $()
3434
dealloc_stack %allocation : $*Builtin.SILToken

test/SILOptimizer/package-cmo-deserialize-for-external-client.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@
3030
// CHECK-INPKG: sil_vtable Pub {
3131
// CHECK-INPKG: #Pub.pubVar!getter: (Pub) -> () -> Int : @$s3Lib3PubC6pubVarSivg // Pub.pubVar.getter
3232
// CHECK-INPKG: #Pub.pubVar!setter: (Pub) -> (Int) -> () : @$s3Lib3PubC6pubVarSivs // Pub.pubVar.setter
33-
// CHECK-INPKG: #Pub.pubVar!modify: (Pub) -> () -> () : @$s3Lib3PubC6pubVarSivM // Pub.pubVar.modify
33+
// CHECK-INPKG: #Pub.pubVar!modify: (Pub) -> @yield_once () -> inout @yields Int : @$s3Lib3PubC6pubVarSivM // Pub.pubVar.modify
3434
// CHECK-INPKG: #Pub.pkgVar!getter: (Pub) -> () -> Int : @$s3Lib3PubC6pkgVarSivg // Pub.pkgVar.getter
3535
// CHECK-INPKG: #Pub.pkgVar!setter: (Pub) -> (Int) -> () : @$s3Lib3PubC6pkgVarSivs // Pub.pkgVar.setter
36-
// CHECK-INPKG: #Pub.pkgVar!modify: (Pub) -> () -> () : @$s3Lib3PubC6pkgVarSivM // Pub.pkgVar.modify
36+
// CHECK-INPKG: #Pub.pkgVar!modify: (Pub) -> @yield_once () -> inout @yields Int : @$s3Lib3PubC6pkgVarSivM // Pub.pkgVar.modify
3737
// CHECK-INPKG: #Pub.init!allocator: (Pub.Type) -> (Int) -> Pub : @$s3Lib3PubCyACSicfC // Pub.__allocating_init(_:)
3838
// CHECK-INPKG: #Pub.deinit!deallocator: @$s3Lib3PubCfD // Pub.__deallocating_deinit
3939

4040
// CHECK-INPKG: sil_witness_table public_external Pub: PubProto module Lib {
4141
// CHECK-INPKG: method #PubProto.pubVar!getter: <Self where Self : PubProto> (Self) -> () -> Int : @$s3Lib3PubCAA0B5ProtoA2aDP6pubVarSivgTW // protocol witness for PubProto.pubVar.getter in conformance Pub
4242
// CHECK-INPKG: method #PubProto.pubVar!setter: <Self where Self : PubProto> (inout Self) -> (Int) -> () : @$s3Lib3PubCAA0B5ProtoA2aDP6pubVarSivsTW // protocol witness for PubProto.pubVar.setter in conformance Pub
43-
// CHECK-INPKG: method #PubProto.pubVar!modify: <Self where Self : PubProto> (inout Self) -> () -> () : @$s3Lib3PubCAA0B5ProtoA2aDP6pubVarSivMTW // protocol witness for PubProto.pubVar.modify in conformance Pub
43+
// 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
4444

4545

4646
/// Test 2: They should NOT be deserialized into Client as Lib and Client are NOT in the same package;
@@ -78,17 +78,17 @@
7878
// CHECK-LIB: sil_vtable [serialized_for_package] Pub {
7979
// CHECK-LIB: #Pub.pubVar!getter: (Pub) -> () -> Int : @$s3Lib3PubC6pubVarSivg // Pub.pubVar.getter
8080
// CHECK-LIB: #Pub.pubVar!setter: (Pub) -> (Int) -> () : @$s3Lib3PubC6pubVarSivs // Pub.pubVar.setter
81-
// CHECK-LIB: #Pub.pubVar!modify: (Pub) -> () -> () : @$s3Lib3PubC6pubVarSivM // Pub.pubVar.modify
81+
// CHECK-LIB: #Pub.pubVar!modify: (Pub) -> @yield_once () -> inout @yields Int : @$s3Lib3PubC6pubVarSivM // Pub.pubVar.modify
8282
// CHECK-LIB: #Pub.pkgVar!getter: (Pub) -> () -> Int : @$s3Lib3PubC6pkgVarSivg // Pub.pkgVar.getter
8383
// CHECK-LIB: #Pub.pkgVar!setter: (Pub) -> (Int) -> () : @$s3Lib3PubC6pkgVarSivs // Pub.pkgVar.setter
84-
// CHECK-LIB: #Pub.pkgVar!modify: (Pub) -> () -> () : @$s3Lib3PubC6pkgVarSivM // Pub.pkgVar.modify
84+
// CHECK-LIB: #Pub.pkgVar!modify: (Pub) -> @yield_once () -> inout @yields Int : @$s3Lib3PubC6pkgVarSivM // Pub.pkgVar.modify
8585
// CHECK-LIB: #Pub.init!allocator: (Pub.Type) -> (Int) -> Pub : @$s3Lib3PubCyACSicfC // Pub.__allocating_init(_:)
8686
// CHECK-LIB: #Pub.deinit!deallocator: @$s3Lib3PubCfD // Pub.__deallocating_deinit
8787

8888
// CHECK-LIB: sil_witness_table [serialized_for_package] Pub: PubProto module Lib {
8989
// CHECK-LIB: method #PubProto.pubVar!getter: <Self where Self : PubProto> (Self) -> () -> Int : @$s3Lib3PubCAA0B5ProtoA2aDP6pubVarSivgTW // protocol witness for PubProto.pubVar.getter in conformance Pub
9090
// CHECK-LIB: method #PubProto.pubVar!setter: <Self where Self : PubProto> (inout Self) -> (Int) -> () : @$s3Lib3PubCAA0B5ProtoA2aDP6pubVarSivsTW // protocol witness for PubProto.pubVar.setter in conformance Pub
91-
// CHECK-LIB: method #PubProto.pubVar!modify: <Self where Self : PubProto> (inout Self) -> () -> () : @$s3Lib3PubCAA0B5ProtoA2aDP6pubVarSivMTW // protocol witness for PubProto.pubVar.modify in conformance Pub
91+
// 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
9292

9393

9494
//--- Lib.swift

test/SILOptimizer/specialize_opaque_result_types.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ bb0(%0 : $*Optional<τ_0_0.Element>, %1 : $*IndexingIterator<τ_0_0>):
5353
copy_addr %3 to [init] %22 : $*τ_0_0.Index
5454
%24 = alloc_stack $τ_0_0
5555
copy_addr [take] %20 to [init] %24 : $*τ_0_0
56-
%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
56+
%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
5757

5858
// The specialized begin apply %26<Test> has a result type of t_0_0.Element
5959
// which works out to be an opaque result type whose underlying type is Int64.

test/SILOptimizer/specialize_opaque_result_types_ossa.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ bb0(%0 : $*Optional<τ_0_0.Element>, %1 : $*IndexingIterator<τ_0_0>):
5252
copy_addr %3 to [init] %22 : $*τ_0_0.Index
5353
%24 = alloc_stack $τ_0_0
5454
copy_addr [take] %20 to [init] %24 : $*τ_0_0
55-
%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
55+
%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
5656

5757
// The specialized begin apply %26<Test> has a result type of t_0_0.Element
5858
// which works out to be an opaque result type whose underlying type is Int64.

0 commit comments

Comments
 (0)