File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -2637,6 +2637,10 @@ void TypeChecker::addImplicitDynamicAttribute(Decl *D) {
2637
2637
// Don't add dynamic to functions with a cdecl.
2638
2638
if (FD->getAttrs ().hasAttribute <CDeclAttr>())
2639
2639
return ;
2640
+ // Don't add dynamic to local function definitions.
2641
+ if (!FD->getDeclContext ()->isTypeContext () &&
2642
+ FD->getDeclContext ()->isLocalContext ())
2643
+ return ;
2640
2644
}
2641
2645
2642
2646
// Don't add dynamic if accessor is inlinable or tranparent.
Original file line number Diff line number Diff line change @@ -367,3 +367,18 @@ var x = 10
367
367
defer {
368
368
let y = x
369
369
}
370
+
371
+ // IMPLICIT-LABEL: sil [dynamically_replacable] [ossa] @$s23dynamically_replaceable16testWithLocalFunyyF
372
+ // IMPLICIT-LABEL: sil private [ossa] @$s23dynamically_replaceable16testWithLocalFunyyF05localF0L_yyF
373
+ // IMPLICIT-LABEL: sil private [ossa] @$s23dynamically_replaceable16testWithLocalFunyyF05localF0L_yyF0geF0L_yyF
374
+ // IMPLICIT-LABEL: sil private [ossa] @$s23dynamically_replaceable16testWithLocalFunyyFyycfU_
375
+ public func testWithLocalFun( ) {
376
+ func localFun( ) {
377
+ func localLocalFun( ) { print ( " bar " ) }
378
+ print ( " foo " )
379
+ localLocalFun ( )
380
+ }
381
+ localFun ( )
382
+ let unamedClosure = { print ( " foo " ) }
383
+ unamedClosure ( )
384
+ }
You can’t perform that action at this time.
0 commit comments