Skip to content

Commit

Permalink
Rework function conversion logic for propagating ExtInfo.
Browse files Browse the repository at this point in the history
The desired ExtInfo here is not a clean derivation from either the source  or destination ExtInfo anymore, so it's clearer and more maintainable to construct a new EI from whole cloth. Response to @jrose-apple's code review.
  • Loading branch information
jckarter committed Nov 4, 2015
1 parent 71485b3 commit 2cf7f18
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/Sema/CSApply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4827,13 +4827,13 @@ Expr *ExprRewriter::coerceToType(Expr *expr, Type toType,
auto fromEI = fromFunc->getExtInfo(), toEI = toFunc->getExtInfo();
if ((toEI.isNoEscape() && !fromEI.isNoEscape()) ||
(toEI.isNoReturn() && !fromEI.isNoReturn())) {
auto newToEI =
toEI.withIsNoReturn(toEI.isNoReturn()|fromEI.isNoReturn())
.withNoEscape(toEI.isNoEscape()|fromEI.isNoEscape())
.withThrows(toEI.throws()&fromEI.throws())
.withRepresentation(fromEI.getRepresentation());
swift::AnyFunctionType::ExtInfo newEI(fromEI.getRepresentation(),
toEI.isNoReturn() | fromEI.isNoReturn(),
toEI.isAutoClosure(),
toEI.isNoEscape() | fromEI.isNoEscape(),
toEI.throws() & fromEI.throws());
auto newToType = FunctionType::get(fromFunc->getInput(),
fromFunc->getResult(), newToEI);
fromFunc->getResult(), newEI);
if (applyTypeToClosureExpr(expr, newToType)) {
fromFunc = newToType;
// Propagating the bits in might have satisfied the entire
Expand Down

0 comments on commit 2cf7f18

Please sign in to comment.