Skip to content

[5.9] [CS] A couple of ExprPattern conjunction fixes #66566

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 2 commits into from
Jun 13, 2023
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
4 changes: 0 additions & 4 deletions lib/Sema/CSGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2949,10 +2949,6 @@ namespace {
PreWalkAction walkToDeclPre(Decl *D) override {
return Action::VisitChildrenIf(isa<PatternBindingDecl>(D));
}

PreWalkResult<Pattern *> walkToPatternPre(Pattern *P) override {
return Action::SkipChildren(P);
}
} collectVarRefs(CS);

// Walk the capture list if this closure has one, because it could
Expand Down
4 changes: 3 additions & 1 deletion lib/Sema/CSSyntacticElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2625,8 +2625,10 @@ void ConjunctionElement::findReferencedVariables(
}

if (element.is<Decl *>() || element.is<StmtConditionElement *>() ||
element.is<Expr *>() || element.isStmt(StmtKind::Return))
element.is<Expr *>() || element.isPattern(PatternKind::Expr) ||
element.isStmt(StmtKind::Return)) {
element.walk(refFinder);
}
}

Type constraints::isPlaceholderVar(PatternBindingDecl *PB) {
Expand Down
36 changes: 36 additions & 0 deletions test/Constraints/issue-66561.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// RUN: %target-typecheck-verify-swift

// https://github.com/apple/swift/issues/66561

@propertyWrapper
struct WrapperValue<Value> {
var value: Value
init(wrappedValue: Value) {
self.value = wrappedValue
}

var projectedValue: Self {
return self
}

var wrappedValue: Value {
get {
self.value
}
set {
self.value = newValue
}
}
}

func test() {
let _ = {
@WrapperValue var value: Bool = false
switch value {
case $value.wrappedValue:
break
default:
break
}
}
}
25 changes: 25 additions & 0 deletions test/Constraints/rdar110617471.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// RUN: %target-typecheck-verify-swift

// rdar://110617471: Make sure we can type-check this.
class C {
var prop = 0
}

func foo(_ fn: () -> Void) {}

class D {
let c = C()

func bar() {
foo { [c] in
foo {
switch 0 {
case c.prop:
break
default:
break
}
}
}
}
}