Skip to content

Commit 0b4ec1c

Browse files
committed
[ConstraintSystem] Add accessor to check whether target represents async let init
1 parent cc87566 commit 0b4ec1c

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1879,6 +1879,17 @@ class SolutionApplicationTarget {
18791879
!expression.pattern->isImplicit();
18801880
}
18811881

1882+
/// Check whether this is an initializaion for `async let` pattern.
1883+
bool isAsyncLetInitializer() const {
1884+
if (!(kind == Kind::expression &&
1885+
expression.contextualPurpose == CTP_Initialization))
1886+
return false;
1887+
1888+
if (auto *PBD = getInitializationPatternBindingDecl())
1889+
return PBD->isAsyncLet();
1890+
return false;
1891+
}
1892+
18821893
/// Whether to bind the types of any variables within the pattern via
18831894
/// one-way constraints.
18841895
bool shouldBindPatternVarsOneWay() const {

lib/Sema/CSApply.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8279,12 +8279,9 @@ static Optional<SolutionApplicationTarget> applySolutionToInitialization(
82798279

82808280
// For an async let, wrap the initializer appropriately to make it a child
82818281
// task.
8282-
if (auto patternBinding = target.getInitializationPatternBindingDecl()) {
8283-
if (patternBinding->isAsyncLet()) {
8284-
resultTarget.setExpr(
8285-
wrapAsyncLetInitializer(
8286-
cs, resultTarget.getAsExpr(), resultTarget.getDeclContext()));
8287-
}
8282+
if (target.isAsyncLetInitializer()) {
8283+
resultTarget.setExpr(wrapAsyncLetInitializer(
8284+
cs, resultTarget.getAsExpr(), resultTarget.getDeclContext()));
82888285
}
82898286

82908287
return resultTarget;

0 commit comments

Comments
 (0)