Skip to content

Commit acff9ee

Browse files
authored
Merge pull request #63456 from hamishknight/connect-var
2 parents 70a1f9f + 6c4b3da commit acff9ee

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

lib/Sema/CSSyntacticElement.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,24 +227,24 @@ class TypeVariableRefFinder : public ASTWalker {
227227
}
228228
};
229229

230-
/// Find any references to not yet resolved outer closure parameters
231-
/// used in the body of the inner closure. This is required because
230+
/// Find any references to not yet resolved outer VarDecls (including closure
231+
/// parameters) used in the body of the inner closure. This is required because
232232
/// isolated conjunctions, just like single-expression closures, have
233233
/// to be connected to type variables they are going to use, otherwise
234234
/// they'll get placed in a separate solver component and would never
235235
/// produce a solution.
236-
class UnresolvedClosureParameterCollector : public ASTWalker {
236+
class UnresolvedVarCollector : public ASTWalker {
237237
ConstraintSystem &CS;
238238

239239
llvm::SmallSetVector<TypeVariableType *, 4> Vars;
240240

241241
public:
242-
UnresolvedClosureParameterCollector(ConstraintSystem &cs) : CS(cs) {}
242+
UnresolvedVarCollector(ConstraintSystem &cs) : CS(cs) {}
243243

244244
PreWalkResult<Expr *> walkToExprPre(Expr *expr) override {
245245
if (auto *DRE = dyn_cast<DeclRefExpr>(expr)) {
246246
auto *decl = DRE->getDecl();
247-
if (isa<ParamDecl>(decl)) {
247+
if (isa<VarDecl>(decl)) {
248248
if (auto type = CS.getTypeIfAvailable(decl)) {
249249
if (auto *typeVar = type->getAs<TypeVariableType>()) {
250250
Vars.insert(typeVar);
@@ -342,7 +342,7 @@ static void createConjunction(ConstraintSystem &cs,
342342
isIsolated = true;
343343
}
344344

345-
UnresolvedClosureParameterCollector paramCollector(cs);
345+
UnresolvedVarCollector paramCollector(cs);
346346

347347
for (const auto &entry : elements) {
348348
ASTNode element = std::get<0>(entry);

test/Constraints/rdar105080067.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
// rdar://105080067 - This isn't currently allowed but make sure we don't
4+
// emit a spurious "cannot reference invalid declaration" error.
5+
for b in [true] where if b { true } else { false } {}
6+
// expected-error@-1 {{'if' may only be used as expression in return, throw, or as the source of an assignment}}

0 commit comments

Comments
 (0)