Skip to content

Commit 8b4d589

Browse files
committed
Sema: Fix effect checking issues with 'async let' and string interpolation
1 parent ce23d97 commit 8b4d589

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2497,10 +2497,14 @@ FunctionType::ExtInfo ConstraintSystem::closureEffects(ClosureExpr *expr) {
24972497

24982498
bool walkToDeclPre(Decl *decl) override {
24992499
// Do not walk into function or type declarations.
2500-
if (!isa<PatternBindingDecl>(decl))
2501-
return false;
2500+
if (auto *patternBinding = dyn_cast<PatternBindingDecl>(decl)) {
2501+
if (patternBinding->isAsyncLet())
2502+
FoundAsync = true;
25022503

2503-
return true;
2504+
return true;
2505+
}
2506+
2507+
return false;
25042508
}
25052509

25062510
std::pair<bool, Stmt *> walkToStmtPre(Stmt *stmt) override {

lib/Sema/TypeCheckEffects.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,17 +1153,14 @@ class ApplyClassifier {
11531153
return ShouldNotRecurse;
11541154
}
11551155
ShouldRecurse_t checkAsyncLet(PatternBindingDecl *patternBinding) {
1156-
// FIXME
1157-
llvm_unreachable("Test me");
1158-
// return ShouldRecurse;
1156+
AsyncKind = ConditionalEffectKind::Always;
1157+
return ShouldRecurse;
11591158
}
11601159
ShouldRecurse_t checkThrow(ThrowStmt *E) {
11611160
return ShouldRecurse;
11621161
}
11631162
ShouldRecurse_t checkInterpolatedStringLiteral(InterpolatedStringLiteralExpr *E) {
1164-
// FIXME
1165-
llvm_unreachable("Test me");
1166-
//return ShouldRecurse;
1163+
return ShouldRecurse;
11671164
}
11681165

11691166
ShouldRecurse_t checkIfConfig(IfConfigDecl *D) {

test/Concurrency/reasync.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,22 @@ func invalidReasyncBody(_: () async -> ()) reasync {
128128
func validReasyncBody(_ fn: () async -> ()) reasync {
129129
await fn()
130130
}
131+
132+
//// String interpolation
133+
134+
func reasyncWithAutoclosure2(_: @autoclosure () async -> String) reasync {}
135+
136+
func callReasyncWithAutoclosure3() {
137+
let world = 123
138+
reasyncWithAutoclosure2("Hello \(world)")
139+
}
140+
141+
//// async let
142+
143+
func callReasyncWithAutoclosure4(_: () async -> ()) reasync {
144+
await reasyncFunction {
145+
async let x = 123
146+
147+
_ = await x
148+
}
149+
}

0 commit comments

Comments
 (0)