Skip to content

IDE: Don't crash in type reconstruction if local types contain subscripts #15285

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
Mar 16, 2018
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
7 changes: 7 additions & 0 deletions lib/IDE/TypeReconstruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,13 @@ FindNamedDecls(ASTContext *ast, const DeclBaseName &name, VisitNodeResult &resul
}

} else if (auto FD = dyn_cast<AbstractFunctionDecl>(parent_decl)) {
// FIXME: We should not end up here at all. For some reason we're trying
// to look up members of a local type inside the parent context of the
// local type.
//
// This code path is broken and is about to be replaced.
if (name.isSpecial())
return result._decls.size();

// Do a local lookup into the function, using the end loc to approximate
// being able to see all the local variables.
Expand Down
24 changes: 21 additions & 3 deletions test/IDE/reconstruct_type_from_mangled_name.swift
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,27 @@ func hasLocalDecls() {

// FIXME
// CHECK: decl: FAILURE for 'LocalType'
// The following is the implicit ctor
// CHECK: decl: FAILURE for ''
struct LocalType {}
struct LocalType {
// CHECK: FAILURE for 'localMethod'
func localMethod() {}

// CHECK: FAILURE for 'subscript'
subscript(x: Int) { get {} set {} }

// CHECK: decl: FAILURE for ''
// CHECK: decl: FAILURE for ''
// CHECK: decl: FAILURE for ''

}

// FIXME
// CHECK: decl: FAILURE for 'LocalClass'
class LocalClass {
// CHECK: FAILURE for 'deinit'
deinit {}

// CHECK: decl: FAILURE for ''
}

// CHECK: decl: FAILURE for 'LocalAlias'
typealias LocalAlias = LocalType
Expand Down