Skip to content

[CSApply] Don't attempt to mark autoclosures as non-implicit #81422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/Sema/CSApply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8656,7 +8656,10 @@ Expr *ExprRewriter::finishApply(ApplyExpr *apply, Type openedType,
AccessSemantics::Ordinary);
if (!declRef)
return nullptr;
declRef->setImplicit(apply->isImplicit());

if (!isa<AutoClosureExpr>(declRef))
declRef->setImplicit(apply->isImplicit());

apply->setFn(declRef);

// Tail-recur to actually call the constructor.
Expand Down
19 changes: 19 additions & 0 deletions test/Concurrency/attr_execution/adoption_mode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,22 @@ do {
}
}

// The compiler used to mark autoclosure in `MyThing` reference as "non-implicit"
// which caused a crash in migration mode because it assumes that autoclosures
// are always implicit.
do {
struct Other {
init(test: Int) {}
}

struct S<T> {
typealias MyThing = Other
var value: T
}

func test(c: S<Int?>) {
_ = c.value.map {
type(of: c).MyThing(test: $0) // Ok (used to crash due to autoclosure use)
}
}
}