Skip to content

[CodeCompletion] Delete expr type state after getting expr completions #7930

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 6, 2017
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/IDE/CodeCompletion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3591,6 +3591,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
bool IncludeTopLevel = false,
bool RequestCache = true,
bool LiteralCompletions = true) {
ExprType = Type();
Kind = LookupKind::ValueInDeclContext;
NeedLeadingDot = false;
FilteredDeclConsumer Consumer(*this, Filter);
Expand Down
52 changes: 52 additions & 0 deletions test/IDE/complete_with_visible_members.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// RUN: %swift-ide-test -code-completion -code-completion-token=A -source-filename %s
// RUN: %swift-ide-test -code-completion -code-completion-token=B -source-filename %s
// RUN: %swift-ide-test -code-completion -code-completion-token=C -source-filename %s
// RUN: %swift-ide-test -code-completion -code-completion-token=D -source-filename %s
// RUN: %swift-ide-test -code-completion -code-completion-token=E -source-filename %s
// RUN: %swift-ide-test -code-completion -code-completion-token=F -source-filename %s

// Make sure that visible members don't mess up code completion,
// having seen a constructor for an incompatible declaration.

class CompeteInMethod {
// Here, the method foo is actually visible at the
// point of code-completion.
func foo() {
String(#^A^#
}
}

class CompleteInVar {
// Same here - var decls are added to code completion results
// in a different but similarly shaped code path. So here,
// the var x is actually visible at the point of code-completion.
var x: Int {
String(#^B^#
}
}

class CompleteOutsideMethod {
func foo() {}
init() {
String(#^C^#
}
}

class CompleteOutsideVar {
var x: Int { return 1 }
init() {
String(#^D^#
}
}

class CompleteInsideGenericFunc {
func foo<S: Sequence>(x: S) {
String(#^E^#
}
}

class CompleteInsideGenericClass<S: Sequence> {
func foo(x: S) {
String(#^F^#
}
}