File tree 3 files changed +20
-10
lines changed
test/SourceKit/CursorInfo
3 files changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,9 @@ namespace {
34
34
// MARK: - Utilities
35
35
36
36
void typeCheckDeclAndParentClosures (ValueDecl *VD) {
37
+ if (!VD) {
38
+ return ;
39
+ }
37
40
// We need to type check any parent closures because their types are
38
41
// encoded in the USR of ParentContexts in the cursor info response.
39
42
auto DC = VD->getDeclContext ();
Original file line number Diff line number Diff line change @@ -2393,8 +2393,6 @@ bool TypeCheckASTNodeAtLocRequest::evaluate(
2393
2393
}
2394
2394
}
2395
2395
2396
- bool LeaveBodyUnchecked = !ctx.CompletionCallback ;
2397
-
2398
2396
// The enclosing closure might be a single expression closure or a function
2399
2397
// builder closure. In such cases, the body elements are type checked with
2400
2398
// the closure itself. So we need to try type checking the enclosing closure
@@ -2418,17 +2416,13 @@ bool TypeCheckASTNodeAtLocRequest::evaluate(
2418
2416
auto ActorIsolation = determineClosureActorIsolation (
2419
2417
CE, __Expr_getType, __AbstractClosureExpr_getActorIsolation);
2420
2418
CE->setActorIsolation (ActorIsolation);
2421
- if (!LeaveBodyUnchecked) {
2422
- // Type checking the parent closure also type checked this node.
2423
- // Nothing to do anymore.
2424
- return false ;
2425
- }
2426
- if (CE->getBodyState () != ClosureExpr::BodyState::ReadyForTypeChecking)
2427
- return false ;
2419
+ // Type checking the parent closure also type checked this node.
2420
+ // Nothing to do anymore.
2421
+ return false ;
2428
2422
}
2429
2423
}
2430
2424
2431
- TypeChecker::typeCheckASTNode (finder.getRef (), DC, LeaveBodyUnchecked);
2425
+ TypeChecker::typeCheckASTNode (finder.getRef (), DC, /* LeaveBodyUnchecked= */ false );
2432
2426
return false ;
2433
2427
}
2434
2428
Original file line number Diff line number Diff line change
1
+ struct MyStruct {
2
+ var identifier : String
3
+ }
4
+
5
+ func takeClosure( _ x: ( ) -> Void ) { }
6
+
7
+ func test( ) {
8
+ takeClosure {
9
+ let foo = MyStruct ( )
10
+ // RUN: %sourcekitd-test -req=cursor -pos=%(line + 1):5 %s -- %s
11
+ foo. identifier = " \( item. category) # \( item. name) "
12
+ }
13
+ }
You can’t perform that action at this time.
0 commit comments