Skip to content

Commit 41301c2

Browse files
authored
Merge pull request #30542 from marcrasi/fix-autocomplete-crash-callasfunction
2 parents 0374da6 + 5772ddd commit 41301c2

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/IDE/CodeCompletion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3153,7 +3153,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
31533153

31543154
// SE-0253: Callable values of user-defined nominal types.
31553155
if (FD->isCallAsFunctionMethod() && !HaveDot &&
3156-
!ExprType->is<AnyMetatypeType>()) {
3156+
(!ExprType || !ExprType->is<AnyMetatypeType>())) {
31573157
Type funcType = getTypeOfMember(FD, dynamicLookupInfo)
31583158
->castTo<AnyFunctionType>()
31593159
->getResult();

test/IDE/complete_crashes.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,3 +378,14 @@ struct test_54215016 {
378378
// RDAR_54215016: Begin completions
379379
}
380380
}
381+
382+
// RUN: %target-swift-ide-test -code-completion -code-completion-token=CRASH_CALL_AS_FUNCTION -source-filename=%s | %FileCheck %s -check-prefix=CRASH_CALL_AS_FUNCTION
383+
protocol HasCallAsFunctionRequirement {
384+
func callAsFunction()
385+
}
386+
struct StructWithCallAsFunction: HasCallAsFunctionRequirement {
387+
let f = #^CRASH_CALL_AS_FUNCTION^#
388+
func callAsFunction() {}
389+
}
390+
// CRASH_CALL_AS_FUNCTION: Begin completion
391+
// CRASH_CALL_AS_FUNCTION: End completions

0 commit comments

Comments
 (0)