Skip to content

Commit 60dd394

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 eeb3963 commit 60dd394

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
@@ -1839,24 +1839,13 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
18391839
SILFunctionConventions substConv(substTy, F.getModule());
18401840
unsigned appliedArgStartIdx =
18411841
substConv.getNumSILArguments() - PAI->getNumArguments();
1842-
bool isSendableAndStageIsCanonical =
1843-
PAI->getFunctionType()->isSendable() &&
1844-
F.getModule().getStage() >= SILStage::Canonical;
18451842
for (auto p : llvm::enumerate(PAI->getArguments())) {
18461843
requireSameType(
18471844
p.value()->getType(),
18481845
substConv.getSILArgumentType(appliedArgStartIdx + p.index(),
18491846
F.getTypeExpansionContext()),
18501847
"applied argument types do not match suffix of function type's "
18511848
"inputs");
1852-
1853-
// TODO: Expand this to also be true for address only types.
1854-
if (isSendableAndStageIsCanonical)
1855-
require(
1856-
!p.value()->getType().getASTType()->is<SILBoxType>() ||
1857-
p.value()->getType().getSILBoxFieldType(&F).isAddressOnly(F),
1858-
"Concurrent partial apply in canonical SIL with a loadable box "
1859-
"type argument?!");
18601849
}
18611850

18621851
// 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)