Skip to content

[ConstraintSystem] Ignore patterns in linked expression analysis #18487

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
Aug 4, 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
16 changes: 16 additions & 0 deletions lib/Sema/CSGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ namespace {

/// \brief Ignore declarations.
bool walkToDeclPre(Decl *decl) override { return false; }

/// \brief Ignore patterns.
std::pair<bool, Pattern*> walkToPatternPre(Pattern *pat) override {
return { false, pat };
}

/// \brief Ignore types.
bool walkToTypeLocPre(TypeLoc &TL) override { return false; }
};

/// Given a collection of "linked" expressions, analyzes them for
Expand Down Expand Up @@ -338,6 +346,14 @@ namespace {

/// \brief Ignore declarations.
bool walkToDeclPre(Decl *decl) override { return false; }

/// \brief Ignore patterns.
std::pair<bool, Pattern*> walkToPatternPre(Pattern *pat) override {
return { false, pat };
}

/// \brief Ignore types.
bool walkToTypeLocPre(TypeLoc &TL) override { return false; }
};

/// For a given expression, given information that is global to the
Expand Down
10 changes: 10 additions & 0 deletions test/IDE/complete_crashes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -357,3 +357,13 @@ extension Foo {
// RDAR_41234606-DAG: Decl[AssociatedType]/Super: .Element; name=Element
// RDAR_41234606-DAG: Decl[AssociatedType]/Super: .Iterator; name=Iterator
// RDAR_41234606: End completions

// rdar://problem/41071587
// RUN: %target-swift-ide-test -code-completion -code-completion-token=RDAR_41071587 -source-filename=%s | %FileCheck %s -check-prefix=RDAR_41071587
func test_41071587(x: Any) {
switch x {
case (let (_, _)) #^RDAR_41071587^#:
()
}
}
// RDAR_41071587: Begin completions
4 changes: 4 additions & 0 deletions test/Parse/matching_patterns.swift
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ case (_, var e, 3) +++ (1, 2, 3):
// expected-error@-1{{'_' can only appear in a pattern}}
// expected-error@-2{{'var' binding pattern cannot appear in an expression}}
()
case (let (_, _, _)) + 1:
// expected-error@-1 2 {{'var' binding pattern cannot appear in an expression}}
// expected-error@-2 {{expression pattern of type 'Int' cannot match values of type '(Int, Int, Int)'}}
()
}

// FIXME: We don't currently allow subpatterns for "isa" patterns that
Expand Down