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 {
550
550
}
551
551
552
552
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
-
557
553
// Only visit a node that has a corresponding concrete syntax node if we are
558
554
// already walking that concrete syntax node.
559
555
auto *concreteDecl = concreteSyntaxDeclForAvailableAttribute (D);
@@ -568,6 +564,12 @@ class TypeRefinementContextBuilder : private ASTWalker {
568
564
PreWalkAction walkToDeclPre (Decl *D) override {
569
565
PrettyStackTraceDecl trace (stackTraceAction (), D);
570
566
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
+
571
573
if (shouldSkipDecl (D))
572
574
return Action::SkipNode ();
573
575
Original file line number Diff line number Diff line change @@ -208,6 +208,16 @@ func functionWithWhile() {
208
208
}
209
209
}
210
210
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
+
211
221
// CHECK-NEXT: {{^}} (decl_implicit version=50 decl=extension.SomeClass
212
222
// CHECK-NEXT: {{^}} (decl version=51 decl=extension.SomeClass
213
223
// 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
28
28
29
29
// Functions without annotations should reflect the minimum deployment target.
30
30
func 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
+ }
32
47
33
48
let _: Int = globalFuncAvailableOn10_9 ( )
34
49
You can’t perform that action at this time.
0 commit comments