Skip to content

Commit b48d9d2

Browse files
author
Amritpan Kaur
committed
[CSApply] changes.
1 parent 3a38d7a commit b48d9d2

File tree

1 file changed

+47
-8
lines changed

1 file changed

+47
-8
lines changed

lib/Sema/CSApply.cpp

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8995,14 +8995,31 @@ ExprWalker::rewriteTarget(SolutionApplicationTarget target) {
89958995
if (cs.isDebugMode()) {
89968996
// If target is a multi-statement closure or
89978997
// a tap expression, expression will not be fully
8998-
// type checked until these types are visited in
8998+
// type checked until these expressions are visited in
89998999
// processDelayed().
9000+
bool isPartial = false;
9001+
resultExpr->forEachChildExpr([&](Expr *child) -> Expr * {
9002+
if (auto *closure = dyn_cast<ClosureExpr>(child)) {
9003+
if (!closure->hasSingleExpressionBody()) {
9004+
isPartial = true;
9005+
return nullptr;
9006+
}
9007+
}
9008+
if (isa<TapExpr>(child)) {
9009+
isPartial = true;
9010+
return nullptr;
9011+
}
9012+
return child;
9013+
});
9014+
90009015
auto &log = llvm::errs();
9001-
if (!ClosuresToTypeCheck.empty() || !TapsToTypeCheck.empty()) {
9016+
if (isPartial) {
90029017
log << "---Partially type-checked expression---\n";
9003-
resultExpr->dump(log);
9004-
log << "\n";
9018+
} else {
9019+
log << "---Type-checked expression---\n";
90059020
}
9021+
resultExpr->dump(log);
9022+
log << "\n";
90069023
}
90079024
}
90089025

@@ -9052,7 +9069,7 @@ Optional<SolutionApplicationTarget> ConstraintSystem::applySolution(
90529069
auto resultTarget = walker.rewriteTarget(target);
90539070
if (!resultTarget)
90549071
return None;
9055-
9072+
90569073
// Visit closures that have non-single expression bodies, tap expressions,
90579074
// and possibly other types of AST nodes which could only be processed
90589075
// after contextual expression.
@@ -9061,16 +9078,38 @@ Optional<SolutionApplicationTarget> ConstraintSystem::applySolution(
90619078
// If any of them failed to type check, bail.
90629079
if (hadError)
90639080
return None;
9064-
9065-
rewriter.finalize();
90669081

9067-
if (isDebugMode()) {
9082+
bool isPartial = false;
9083+
resultTarget->getAsExpr()->forEachChildExpr([&](Expr *child) -> Expr * {
9084+
if (auto *closure = dyn_cast<ClosureExpr>(child)) {
9085+
if (!closure->hasSingleExpressionBody()) {
9086+
isPartial = true;
9087+
return nullptr;
9088+
}
9089+
}
9090+
if (isa<TapExpr>(child)) {
9091+
isPartial = true;
9092+
return nullptr;
9093+
}
9094+
return child;
9095+
});
9096+
9097+
if (isPartial) {
90689098
auto &log = llvm::errs();
90699099
log << "---Fully type-checked expression---\n";
90709100
resultTarget->getAsExpr()->dump(log);
90719101
log << "\n";
90729102
}
90739103

9104+
rewriter.finalize();
9105+
9106+
// if (isDebugMode()) {
9107+
// auto &log = llvm::errs();
9108+
// log << "---Fully type-checked expression---\n";
9109+
// resultTarget->getAsExpr()->dump(log);
9110+
// log << "\n";
9111+
//}
9112+
90749113
return resultTarget;
90759114
}
90769115

0 commit comments

Comments
 (0)