File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -527,3 +527,28 @@ func testKeyPathWithClassFinalStoredProperty() {
527
527
// model.
528
528
takesTwoInouts ( & local[ keyPath: getI] , & local[ keyPath: getI] )
529
529
}
530
+
531
+ func takesInoutAndOptionalClosure( _: inout Int , _ f: ( ( ) -> ( ) ) ? ) {
532
+ f!( )
533
+ }
534
+
535
+ // An optional closure is not considered @noescape:
536
+ // This violation will only be caught dynamically.
537
+ //
538
+ // apply %takesInoutAndOptionalClosure(%closure)
539
+ // : $@convention(thin) (@inout Int, @owned Optional<@callee_guaranteed () -> ()>) -> ()
540
+ func testOptionalClosure( ) {
541
+ var x = 0
542
+ takesInoutAndOptionalClosure ( & x) { x += 1 }
543
+ }
544
+
545
+ func takesInoutAndOptionalBlock( _: inout Int , _ f: ( @convention ( block) ( ) -> ( ) ) ? ) {
546
+ f!( )
547
+ }
548
+
549
+ // An optional block is not be considered @noescape.
550
+ // This violation will only be caught dynamically.
551
+ func testOptionalBlock( ) {
552
+ var x = 0
553
+ takesInoutAndOptionalBlock ( & x) { x += 1 }
554
+ }
You can’t perform that action at this time.
0 commit comments