@@ -161,3 +161,66 @@ func useCallerIsolatedDefaultArg() async {
161161// CHECK: // function_ref default argument 0 of
162162// CHECK-NEXT: [[GEN:%.*]] = function_ref @$s4test24callerIsolatedDefaultArg1xySi_tYaFfA_ :
163163// CHECK-NEXT: [[ARG:%.*]] = apply [[GEN]]()
164+
165+ // The following tests failed due to a book-keeping error when processing delayed
166+ // isolated arguments in methods with:
167+ //
168+ // - a `self` parameter
169+ // - delayed arguments that expanded to zero or greater than one value
170+ // - a subsequent delayed argument
171+ //
172+ // https://github.com/swiftlang/swift/issues/84647
173+
174+ @MainActor
175+ enum E {
176+ static func tupleIsolatedDefaultArgStatic(
177+ _: Int ,
178+ x: Int = main_actor_int_x ( ) ,
179+ // need not be isolated defaults
180+ tup: ( Int , Int ) = ( 1 , 2 ) ,
181+ i: Int = 0
182+ ) { }
183+
184+ static func voidIsolatedDefaultArgStatic(
185+ _: Int ,
186+ v: Void = main_actor_void ( ) ,
187+ // need not be isolated defaults
188+ tup: ( Int , Int ) = ( 1 , 2 ) ,
189+ i: Int = 0
190+ ) { }
191+ }
192+
193+ func testTupleIsolatedDefaultArgStatic( ) async {
194+ await E . tupleIsolatedDefaultArgStatic ( 0 )
195+ }
196+
197+ func testVoidIsolatedDefaultArgStatic( ) async {
198+ await E . voidIsolatedDefaultArgStatic ( 0 )
199+ }
200+
201+ @MainActor
202+ final class Klazz {
203+ func tupleIsolatedDefaultArgInstanceMethod(
204+ _: Int ,
205+ x: Int = main_actor_int_x ( ) ,
206+ // need not be isolated defaults
207+ tup: ( Int , Int ) = ( 1 , 2 ) ,
208+ i: Int = 0
209+ ) { }
210+
211+ func voidIsolatedDefaultArgInstanceMethod(
212+ _: Int ,
213+ v: Void = main_actor_void ( ) ,
214+ // need not be isolated defaults
215+ tup: ( Int , Int ) = ( 1 , 2 ) ,
216+ i: Int = 0
217+ ) { }
218+ }
219+
220+ func testTupleIsolatedDefaultArgInstanceMethod( _ klazz: Klazz ) async {
221+ await klazz. tupleIsolatedDefaultArgInstanceMethod ( 0 )
222+ }
223+
224+ func testVoidIsolatedDefaultArgInstanceMethod( _ klazz: Klazz ) async {
225+ await klazz. voidIsolatedDefaultArgInstanceMethod ( 0 )
226+ }
0 commit comments