Skip to content

Commit 8d9d099

Browse files
committed
Simplify the type resolution of for-await-in statements to determine throwing behavior of async sequences
1 parent 00f6af1 commit 8d9d099

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -592,17 +592,9 @@ bool TypeChecker::typeCheckForEachBinding(DeclContext *dc, ForEachStmt *stmt) {
592592
// check to see if the sequence expr is throwing (and async), if so require
593593
// the stmt to have a try loc
594594
if (stmt->getAwaitLoc().isValid()) {
595-
auto Ty = sequence->getType();
596-
if (Ty.isNull()) {
597-
auto DRE = dyn_cast<DeclRefExpr>(sequence);
598-
if (DRE) {
599-
Ty = DRE->getDecl()->getInterfaceType();
600-
}
601-
if (Ty.isNull()) {
602-
return failed();
603-
}
604-
}
605-
595+
// fetch the sequence out of the statement
596+
// else wise the value is potentially unresolved
597+
auto Ty = stmt->getSequence()->getType();
606598
auto module = dc->getParentModule();
607599
auto conformanceRef = module->lookupConformance(Ty, sequenceProto);
608600

0 commit comments

Comments
 (0)