Skip to content

Commit ba0536f

Browse files
authored
Merge pull request swiftlang#38724 from hamishknight/sugary-goodness
2 parents a51b650 + 3a28a52 commit ba0536f

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

lib/AST/ASTVerifier.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,6 +2008,15 @@ class Verifier : public ASTWalker {
20082008
verifyCheckedBase(E);
20092009
}
20102010

2011+
void verifyChecked(ParenExpr *E) {
2012+
PrettyStackTraceExpr debugStack(Ctx, "verifying ParenExpr", E);
2013+
if (!isa<ParenType>(E->getType().getPointer())) {
2014+
Out << "ParenExpr not of ParenType\n";
2015+
abort();
2016+
}
2017+
verifyCheckedBase(E);
2018+
}
2019+
20112020
void verifyChecked(AnyTryExpr *E) {
20122021
PrettyStackTraceExpr debugStack(Ctx, "verifying AnyTryExpr", E);
20132022

lib/Sema/CSApply.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6178,8 +6178,15 @@ static bool applyTypeToClosureExpr(ConstraintSystem &cs,
61786178
Expr *expr, Type toType) {
61796179
// Look through identity expressions, like parens.
61806180
if (auto IE = dyn_cast<IdentityExpr>(expr)) {
6181-
if (!applyTypeToClosureExpr(cs, IE->getSubExpr(), toType)) return false;
6182-
cs.setType(IE, toType);
6181+
if (!applyTypeToClosureExpr(cs, IE->getSubExpr(), toType))
6182+
return false;
6183+
6184+
auto subExprTy = cs.getType(IE->getSubExpr());
6185+
if (isa<ParenExpr>(IE)) {
6186+
cs.setType(IE, ParenType::get(cs.getASTContext(), subExprTy));
6187+
} else {
6188+
cs.setType(IE, subExprTy);
6189+
}
61836190
return true;
61846191
}
61856192

test/expr/closure/nested_inner_closures.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ assert({ () -> Bool in
55
}(), "")
66

77
var x = ({ () -> String in return "s" })()
8+
var y = ((({ () -> String in return "s" })))()

0 commit comments

Comments
 (0)