Skip to content

Commit 43399ba

Browse files
committed
Make sure we propagate @preconcurrency to closures consistently.
The type checker is now permitting `@Sendable` closures whose captures can be by-reference, because we do not error. Remove an aspirational SIL verifier check that banned this.
1 parent 218a3f7 commit 43399ba

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,24 +1846,13 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
18461846
SILFunctionConventions substConv(substTy, F.getModule());
18471847
unsigned appliedArgStartIdx =
18481848
substConv.getNumSILArguments() - PAI->getNumArguments();
1849-
bool isSendableAndStageIsCanonical =
1850-
PAI->getFunctionType()->isSendable() &&
1851-
F.getModule().getStage() >= SILStage::Canonical;
18521849
for (auto p : llvm::enumerate(PAI->getArguments())) {
18531850
requireSameType(
18541851
p.value()->getType(),
18551852
substConv.getSILArgumentType(appliedArgStartIdx + p.index(),
18561853
F.getTypeExpansionContext()),
18571854
"applied argument types do not match suffix of function type's "
18581855
"inputs");
1859-
1860-
// TODO: Expand this to also be true for address only types.
1861-
if (isSendableAndStageIsCanonical)
1862-
require(
1863-
!p.value()->getType().getASTType()->is<SILBoxType>() ||
1864-
p.value()->getType().getSILBoxFieldType(&F).isAddressOnly(F),
1865-
"Concurrent partial apply in canonical SIL with a loadable box "
1866-
"type argument?!");
18671856
}
18681857

18691858
// The arguments to the result function type must match the prefix of the

lib/Sema/CSApply.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5706,8 +5706,17 @@ ArgumentList *ExprRewriter::coerceCallArguments(
57065706
// Quickly test if any further fix-ups for the argument types are necessary.
57075707
auto matches = args->matches(params, [&](Expr *E) { return cs.getType(E); });
57085708
if (matches && !shouldInjectWrappedValuePlaceholder &&
5709-
!paramInfo.anyContextualInfo())
5709+
!paramInfo.anyContextualInfo()) {
5710+
// Propagate preconcurrency to any closure arguments.
5711+
if (preconcurrency) {
5712+
for (const auto &arg : *args) {
5713+
Expr *argExpr = arg.getExpr();
5714+
applyContextualClosureFlags(argExpr, false, false, preconcurrency);
5715+
}
5716+
}
5717+
57105718
return args;
5719+
}
57115720

57125721
// Determine the parameter bindings that were applied.
57135722
auto *locatorPtr = cs.getConstraintLocator(locator);

test/SIL/concurrentclosure_capture_verify_canonical_loadable.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: not --crash %target-sil-opt %s
1+
// RUN: %target-sil-opt %s
22

33
// REQUIRES: concurrency
44

0 commit comments

Comments
 (0)