Skip to content

[SourceKit] Never try to report mangled names for archetypes without contexts. #5435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/AST/USRGeneration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ static inline StringRef getUSRSpacePrefix() {
}

bool ide::printTypeUSR(Type Ty, raw_ostream &OS) {
assert(!Ty->hasArchetype() && "cannot have contextless archetypes mangled.");
using namespace Mangle;
Mangler Mangler(true);
Mangler.mangleTypeForDebugger(Ty->getRValueType(), nullptr);
Expand Down
11 changes: 11 additions & 0 deletions test/SourceKit/CursorInfo/crash2.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
protocol P {
func meth()
}

func foo (t : P) {
t.meth()
}

// RUN: %sourcekitd-test -req=cursor -pos=6:5 %s -- %s | %FileCheck %s -check-prefix=CASE1

// CASE1: source.lang.swift.ref.function.method.instance (2:8-2:14)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a more descriptive file name. Also, we should check that we're getting a reasonable USR still, right?

2 changes: 1 addition & 1 deletion tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ static bool passCursorInfoForDecl(const ValueDecl *VD,
unsigned MangledTypeEnd = SS.size();

unsigned MangledContainerTypeStart = SS.size();
if (ContainerTy) {
if (ContainerTy && !ContainerTy->hasArchetype()) {
llvm::raw_svector_ostream OS(SS);
SwiftLangSupport::printTypeUSR(ContainerTy, OS);
}
Expand Down