File tree Expand file tree Collapse file tree 3 files changed +20
-10
lines changed
test/SourceKit/CursorInfo Expand file tree Collapse file tree 3 files changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,9 @@ namespace {
3434// MARK: - Utilities
3535
3636void typeCheckDeclAndParentClosures (ValueDecl *VD) {
37+ if (!VD) {
38+ return ;
39+ }
3740 // We need to type check any parent closures because their types are
3841 // encoded in the USR of ParentContexts in the cursor info response.
3942 auto DC = VD->getDeclContext ();
Original file line number Diff line number Diff line change @@ -2393,8 +2393,6 @@ bool TypeCheckASTNodeAtLocRequest::evaluate(
23932393 }
23942394 }
23952395
2396- bool LeaveBodyUnchecked = !ctx.CompletionCallback ;
2397-
23982396 // The enclosing closure might be a single expression closure or a function
23992397 // builder closure. In such cases, the body elements are type checked with
24002398 // the closure itself. So we need to try type checking the enclosing closure
@@ -2418,17 +2416,13 @@ bool TypeCheckASTNodeAtLocRequest::evaluate(
24182416 auto ActorIsolation = determineClosureActorIsolation (
24192417 CE, __Expr_getType, __AbstractClosureExpr_getActorIsolation);
24202418 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 ;
24282422 }
24292423 }
24302424
2431- TypeChecker::typeCheckASTNode (finder.getRef (), DC, LeaveBodyUnchecked);
2425+ TypeChecker::typeCheckASTNode (finder.getRef (), DC, /* LeaveBodyUnchecked= */ false );
24322426 return false ;
24332427}
24342428
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