mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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:
@@ -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
|
||||
|
||||
@@ -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 =
|
||||
|
||||
12
test/SourceKit/CursorInfo/cursor_in_stdlib_module.swift
Normal file
12
test/SourceKit/CursorInfo/cursor_in_stdlib_module.swift
Normal 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
|
||||
Reference in New Issue
Block a user