Skip to content

Commit 9894eed

Browse files
committed
[code-completion] Fix crash with missing func body in type-checking
We already fail early on a missing body in normal type-checking, but we missed the case where we call typeCheckAbstractFunctionBodyUntil directly, as in code-completion. rdar://problem/28822204
1 parent d822c39 commit 9894eed

7 files changed

+10
-9
lines changed

lib/Sema/TypeCheckStmt.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,6 +1233,9 @@ static void checkDefaultArguments(TypeChecker &tc, ParameterList *params,
12331233

12341234
bool TypeChecker::typeCheckAbstractFunctionBodyUntil(AbstractFunctionDecl *AFD,
12351235
SourceLoc EndTypeCheckLoc) {
1236+
if (!AFD->getBody())
1237+
return false;
1238+
12361239
if (auto *FD = dyn_cast<FuncDecl>(AFD))
12371240
return typeCheckFunctionBodyUntil(FD, EndTypeCheckLoc);
12381241

validation-test/IDE/crashers/008-swift-typechecker-typecheckfunctionbodyuntil.swift

Lines changed: 0 additions & 2 deletions
This file was deleted.

validation-test/IDE/crashers/094-swift-typechecker-lookupmembertype.swift

Lines changed: 0 additions & 4 deletions
This file was deleted.

validation-test/IDE/crashers/107-swift-typechecker-typecheckabstractfunctionbodyuntil.swift

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// RUN: %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s
2+
func a(={#^A^#
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// RUN: %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s
2+
protocol P{typealias e
3+
extension{func i(t:e=[{func#^A^#
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// RUN: %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s
2+
let a{func i(={#^A^#

0 commit comments

Comments
 (0)