Skip to content

Commit 2c0ea13

Browse files
committed
[Sema] Remove some hasError checks for typeCheckPattern
These shouldn't be necessary anymore, we should be able to handle ErrorType patterns.
1 parent 0c58138 commit 2c0ea13

File tree

5 files changed

+6
-21
lines changed

5 files changed

+6
-21
lines changed

lib/Sema/CSGen.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4823,12 +4823,6 @@ generateForEachPreambleConstraints(ConstraintSystem &cs,
48234823
return std::nullopt;
48244824
target.setPattern(pattern);
48254825

4826-
auto contextualPattern = ContextualPattern::forRawPattern(pattern, dc);
4827-
4828-
if (TypeChecker::typeCheckPattern(contextualPattern)->hasError()) {
4829-
return std::nullopt;
4830-
}
4831-
48324826
if (isa<PackExpansionExpr>(forEachExpr)) {
48334827
auto *expansion = cast<PackExpansionExpr>(forEachExpr);
48344828

@@ -4996,10 +4990,6 @@ bool ConstraintSystem::generateConstraints(
49964990
ContextualPattern::forPatternBindingDecl(patternBinding, index);
49974991
Type patternType = TypeChecker::typeCheckPattern(contextualPattern);
49984992

4999-
// Fail early if pattern couldn't be type-checked.
5000-
if (!patternType || patternType->hasError())
5001-
return true;
5002-
50034993
auto *init = patternBinding->getInit(index);
50044994

50054995
if (!init && patternBinding->isDefaultInitializable(index) &&

lib/Sema/TypeCheckStmt.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -905,10 +905,6 @@ typeCheckPatternBindingStmtConditionElement(StmtConditionElement &elt,
905905
// provide type information.
906906
auto contextualPattern = ContextualPattern::forRawPattern(pattern, dc);
907907
Type patternType = TypeChecker::typeCheckPattern(contextualPattern);
908-
if (patternType->hasError()) {
909-
typeCheckPatternFailed();
910-
return true;
911-
}
912908

913909
// If the pattern didn't get a type, it's because we ran into some
914910
// unknown types along the way. We'll need to check the initializer.

lib/Sema/TypeCheckStorage.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -451,12 +451,6 @@ const PatternBindingEntry *PatternBindingEntryRequest::evaluate(
451451
auto contextualPattern =
452452
ContextualPattern::forPatternBindingDecl(binding, entryNumber);
453453
Type patternType = TypeChecker::typeCheckPattern(contextualPattern);
454-
if (patternType->hasError()) {
455-
swift::setBoundVarsTypeError(pattern, Context);
456-
binding->setInvalid();
457-
pattern->setType(ErrorType::get(Context));
458-
return &pbe;
459-
}
460454

461455
llvm::SmallVector<VarDecl *, 2> vars;
462456
binding->getPattern(entryNumber)->collectVariables(vars);

test/Constraints/generics.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,9 @@ do {
472472
}
473473

474474
class testStdlibType {
475-
let _: Array // expected-error {{reference to generic type 'Array' requires arguments in <...>}} {{15-15=<Any>}}
475+
let _: Array
476+
// expected-error@-1 {{reference to generic type 'Array' requires arguments in <...>}} {{15-15=<Any>}}
477+
// expected-error@-2 {{property declaration does not bind any variables}}
476478
}
477479

478480
// rdar://problem/32697033

test/Constraints/patterns.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,4 +840,7 @@ func testUndefinedInClosureVar() {
840840
_ = {
841841
var x: Undefined // expected-error {{cannot find type 'Undefined' in scope}}
842842
}
843+
_ = {
844+
for x: Undefined in [0] {} // expected-error {{cannot find type 'Undefined' in scope}}
845+
}
843846
}

0 commit comments

Comments
 (0)