Skip to content

Commit 336be3c

Browse files
authored
Merge pull request #81453 from xedin/fix-csapply-to-avoid-marking-autoclosure-closures-as-nonimplicit-6.2
[6.2][CSApply] Don't attempt to mark autoclosures as non-implicit
2 parents b8542ba + b967cf4 commit 336be3c

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

lib/Sema/CSApply.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8669,7 +8669,10 @@ Expr *ExprRewriter::finishApply(ApplyExpr *apply, Type openedType,
86698669
AccessSemantics::Ordinary);
86708670
if (!declRef)
86718671
return nullptr;
8672-
declRef->setImplicit(apply->isImplicit());
8672+
8673+
if (!isa<AutoClosureExpr>(declRef))
8674+
declRef->setImplicit(apply->isImplicit());
8675+
86738676
apply->setFn(declRef);
86748677

86758678
// Tail-recur to actually call the constructor.

test/Concurrency/attr_execution/adoption_mode.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,3 +272,22 @@ do {
272272
}
273273
}
274274

275+
// The compiler used to mark autoclosure in `MyThing` reference as "non-implicit"
276+
// which caused a crash in migration mode because it assumes that autoclosures
277+
// are always implicit.
278+
do {
279+
struct Other {
280+
init(test: Int) {}
281+
}
282+
283+
struct S<T> {
284+
typealias MyThing = Other
285+
var value: T
286+
}
287+
288+
func test(c: S<Int?>) {
289+
_ = c.value.map {
290+
type(of: c).MyThing(test: $0) // Ok (used to crash due to autoclosure use)
291+
}
292+
}
293+
}

0 commit comments

Comments
 (0)