Skip to content

Commit 3b3d13c

Browse files
authored
Merge pull request #81422 from xedin/fix-csapply-to-avoid-marking-autoclosure-closures-as-nonimplicit
[CSApply] Don't attempt to mark autoclosures as non-implicit
2 parents ede6e46 + 37e2f37 commit 3b3d13c

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
@@ -8656,7 +8656,10 @@ Expr *ExprRewriter::finishApply(ApplyExpr *apply, Type openedType,
86568656
AccessSemantics::Ordinary);
86578657
if (!declRef)
86588658
return nullptr;
8659-
declRef->setImplicit(apply->isImplicit());
8659+
8660+
if (!isa<AutoClosureExpr>(declRef))
8661+
declRef->setImplicit(apply->isImplicit());
8662+
86608663
apply->setFn(declRef);
86618664

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