mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Sema] Remove some hasError checks for typeCheckPattern
These shouldn't be necessary anymore, we should be able to handle ErrorType patterns.
This commit is contained in:
@@ -4823,12 +4823,6 @@ generateForEachPreambleConstraints(ConstraintSystem &cs,
|
||||
return std::nullopt;
|
||||
target.setPattern(pattern);
|
||||
|
||||
auto contextualPattern = ContextualPattern::forRawPattern(pattern, dc);
|
||||
|
||||
if (TypeChecker::typeCheckPattern(contextualPattern)->hasError()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
if (isa<PackExpansionExpr>(forEachExpr)) {
|
||||
auto *expansion = cast<PackExpansionExpr>(forEachExpr);
|
||||
|
||||
@@ -4996,10 +4990,6 @@ bool ConstraintSystem::generateConstraints(
|
||||
ContextualPattern::forPatternBindingDecl(patternBinding, index);
|
||||
Type patternType = TypeChecker::typeCheckPattern(contextualPattern);
|
||||
|
||||
// Fail early if pattern couldn't be type-checked.
|
||||
if (!patternType || patternType->hasError())
|
||||
return true;
|
||||
|
||||
auto *init = patternBinding->getInit(index);
|
||||
|
||||
if (!init && patternBinding->isDefaultInitializable(index) &&
|
||||
|
||||
@@ -905,10 +905,6 @@ typeCheckPatternBindingStmtConditionElement(StmtConditionElement &elt,
|
||||
// provide type information.
|
||||
auto contextualPattern = ContextualPattern::forRawPattern(pattern, dc);
|
||||
Type patternType = TypeChecker::typeCheckPattern(contextualPattern);
|
||||
if (patternType->hasError()) {
|
||||
typeCheckPatternFailed();
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the pattern didn't get a type, it's because we ran into some
|
||||
// unknown types along the way. We'll need to check the initializer.
|
||||
|
||||
@@ -451,12 +451,6 @@ const PatternBindingEntry *PatternBindingEntryRequest::evaluate(
|
||||
auto contextualPattern =
|
||||
ContextualPattern::forPatternBindingDecl(binding, entryNumber);
|
||||
Type patternType = TypeChecker::typeCheckPattern(contextualPattern);
|
||||
if (patternType->hasError()) {
|
||||
swift::setBoundVarsTypeError(pattern, Context);
|
||||
binding->setInvalid();
|
||||
pattern->setType(ErrorType::get(Context));
|
||||
return &pbe;
|
||||
}
|
||||
|
||||
llvm::SmallVector<VarDecl *, 2> vars;
|
||||
binding->getPattern(entryNumber)->collectVariables(vars);
|
||||
|
||||
@@ -472,7 +472,9 @@ do {
|
||||
}
|
||||
|
||||
class testStdlibType {
|
||||
let _: Array // expected-error {{reference to generic type 'Array' requires arguments in <...>}} {{15-15=<Any>}}
|
||||
let _: Array
|
||||
// expected-error@-1 {{reference to generic type 'Array' requires arguments in <...>}} {{15-15=<Any>}}
|
||||
// expected-error@-2 {{property declaration does not bind any variables}}
|
||||
}
|
||||
|
||||
// rdar://problem/32697033
|
||||
|
||||
@@ -840,4 +840,7 @@ func testUndefinedInClosureVar() {
|
||||
_ = {
|
||||
var x: Undefined // expected-error {{cannot find type 'Undefined' in scope}}
|
||||
}
|
||||
_ = {
|
||||
for x: Undefined in [0] {} // expected-error {{cannot find type 'Undefined' in scope}}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user