File tree Expand file tree Collapse file tree 3 files changed +32
-5
lines changed
Expand file tree Collapse file tree 3 files changed +32
-5
lines changed Original file line number Diff line number Diff line change @@ -550,10 +550,6 @@ class TypeRefinementContextBuilder : private ASTWalker {
550550 }
551551
552552 bool shouldSkipDecl (Decl *D) const {
553- // Implicit decls don't have source locations so they cannot have a TRC.
554- if (D->isImplicit ())
555- return true ;
556-
557553 // Only visit a node that has a corresponding concrete syntax node if we are
558554 // already walking that concrete syntax node.
559555 auto *concreteDecl = concreteSyntaxDeclForAvailableAttribute (D);
@@ -568,6 +564,12 @@ class TypeRefinementContextBuilder : private ASTWalker {
568564 PreWalkAction walkToDeclPre (Decl *D) override {
569565 PrettyStackTraceDecl trace (stackTraceAction (), D);
570566
567+ // Implicit decls don't have source locations so they cannot have a TRC.
568+ // However, some implicit nodes contain non-implicit nodes (e.g. defer
569+ // blocks) so continue rather than skipping the node entirely.
570+ if (D->isImplicit ())
571+ return Action::Continue ();
572+
571573 if (shouldSkipDecl (D))
572574 return Action::SkipNode ();
573575
Original file line number Diff line number Diff line change @@ -208,6 +208,16 @@ func functionWithWhile() {
208208 }
209209}
210210
211+ // CHECK-NEXT: {{^}} (decl version=51 decl=functionWithDefer()
212+ // CHECK-NEXT: {{^}} (condition_following_availability version=52
213+ // CHECK-NEXT: {{^}} (if_then version=52
214+ @available ( OSX 51 , * )
215+ func functionWithDefer( ) {
216+ defer {
217+ if #available( OSX 52 , * ) { }
218+ }
219+ }
220+
211221// CHECK-NEXT: {{^}} (decl_implicit version=50 decl=extension.SomeClass
212222// CHECK-NEXT: {{^}} (decl version=51 decl=extension.SomeClass
213223// CHECK-NEXT: {{^}} (decl_implicit version=51 decl=someStaticPropertyWithClosureInit
Original file line number Diff line number Diff line change @@ -28,7 +28,22 @@ let ignored3: Int = globalFuncAvailableOn52() // expected-error {{'globalFuncAva
2828
2929// Functions without annotations should reflect the minimum deployment target.
3030func functionWithoutAvailability( ) {
31- // expected-note@-1 2{{add @available attribute to enclosing global function}}
31+ // expected-note@-1 5{{add @available attribute to enclosing global function}}
32+
33+ defer {
34+ let _: Int = globalFuncAvailableOn10_9 ( )
35+ let _: Int = globalFuncAvailableOn51 ( ) // expected-error {{'globalFuncAvailableOn51()' is only available in macOS 51 or newer}}
36+ // expected-note@-1 {{add 'if #available' version check}}
37+ let _: Int = globalFuncAvailableOn52 ( ) // expected-error {{'globalFuncAvailableOn52()' is only available in macOS 52 or newer}}
38+ // expected-note@-1 {{add 'if #available' version check}}
39+
40+ if #available( OSX 51 , * ) {
41+ let _: Int = globalFuncAvailableOn10_9 ( )
42+ let _: Int = globalFuncAvailableOn51 ( )
43+ let _: Int = globalFuncAvailableOn52 ( ) // expected-error {{'globalFuncAvailableOn52()' is only available in macOS 52 or newer}}
44+ // expected-note@-1 {{add 'if #available' version check}}
45+ }
46+ }
3247
3348 let _: Int = globalFuncAvailableOn10_9 ( )
3449
You can’t perform that action at this time.
0 commit comments