Skip to content

Commit 68db6a8

Browse files
committed
Test: add coverage for consume in closure
fixes #75487
1 parent df9ff6c commit 68db6a8

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

test/SILOptimizer/noimplicitcopy_consuming_parameters.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -emit-sil %s -verify -sil-verify-all
1+
// RUN: %target-swift-frontend -emit-sil %s -verify -sil-verify-all -disable-availability-checking
22

33
////////////////////////
44
// MARK: Declarations //
@@ -997,3 +997,17 @@ struct TrivialSelfTest {
997997
}
998998

999999
func consumeTrivialSelfTest(_ x: consuming TrivialSelfTest) {}
1000+
1001+
extension AsyncSequence where Element: Sendable {
1002+
consuming func iterate_bad() async { // expected-error {{missing reinitialization of inout parameter 'self' after consume}}
1003+
await withTaskGroup(of: Void.self) { _ in
1004+
var _:AsyncIterator = self.makeAsyncIterator() // expected-note {{consumed here}}
1005+
}
1006+
}
1007+
1008+
consuming func iterate_fixed() async {
1009+
await withTaskGroup(of: Void.self) { [seq = copy self] _ in
1010+
var _:AsyncIterator = seq.makeAsyncIterator()
1011+
}
1012+
}
1013+
}

0 commit comments

Comments
 (0)