[CursorInfo] Fix a bug that caused solver-based cursor info to crash if invoked on a symbol from a different module

This commit is contained in:
Alex Hoppen
2023-02-08 11:26:33 +01:00
parent 3e460630b7
commit a9cba5457c
3 changed files with 23 additions and 3 deletions

View File

@@ -48,9 +48,14 @@ void typeCheckDeclAndParentClosures(ValueDecl *VD) {
DC = DC->getParent();
}
typeCheckASTNodeAtLoc(
TypeCheckASTNodeAtLocContext::declContext(VD->getDeclContext()),
VD->getLoc());
if (!VD->getInterfaceType()) {
// The decl has an interface time if it came from another module. In that
// case, there's nothing to do. Otherwise, type check the decl to get its
// type.
typeCheckASTNodeAtLoc(
TypeCheckASTNodeAtLocContext::declContext(VD->getDeclContext()),
VD->getLoc());
}
if (auto VarD = dyn_cast<VarDecl>(VD)) {
if (VarD->hasAttachedPropertyWrapper()) {
// Type check any attached property wrappers so the annotated declaration

View File

@@ -36,6 +36,9 @@ swift::ide::getSelectedOverloadInfo(const Solution &S,
if (Result.BaseTy) {
Result.BaseTy = S.simplifyType(Result.BaseTy)->getRValueType();
}
if (Result.BaseTy && Result.BaseTy->is<ModuleType>()) {
Result.BaseTy = nullptr;
}
Result.Value = SelectedOverload->choice.getDeclOrNull();
Result.ValueTy =

View File

@@ -0,0 +1,12 @@
func test() {
// RUN: %sourcekitd-test -req=cursor -pos=%(line + 1):9 %s -- %s | %FileCheck %s
Swift.min(1, 2)
}
// CHECK: source.lang.swift.ref.function.free ()
// CHECK-NEXT: min(_:_:)
// CHECK-NEXT: s:s3minyxx_xtSLRzlF
// CHECK-NEXT: source.lang.swift
// CHECK-NEXT: <T where T : Comparable> (T, T) -> T
// CHECK-NEXT: $syxx_xtcSLRzluD
// CHECK-NEXT: Swift