diff --git a/lib/Sema/TypeCheckConcurrency.cpp b/lib/Sema/TypeCheckConcurrency.cpp index ad65ac50991fd..02ca2766edb39 100644 --- a/lib/Sema/TypeCheckConcurrency.cpp +++ b/lib/Sema/TypeCheckConcurrency.cpp @@ -4703,9 +4703,11 @@ ActorIsolation ActorIsolationChecker::determineClosureIsolation( // `nonisolated(nonsending)` inferred from the context makes // the closure caller isolated. - if (auto *closureTy = getType(closure)->getAs()) { - if (closureTy->getIsolation().isNonIsolatedCaller()) - return ActorIsolation::forCallerIsolationInheriting(); + if (auto closureTy = getType(closure)) { + if (auto *closureFnTy = closureTy->getAs()) { + if (closureFnTy->getIsolation().isNonIsolatedCaller()) + return ActorIsolation::forCallerIsolationInheriting(); + } } // If a closure has an isolated parameter, it is isolated to that diff --git a/test/SourceKit/CodeComplete/issue-80985.swift b/test/SourceKit/CodeComplete/issue-80985.swift new file mode 100644 index 0000000000000..de7002fe44519 --- /dev/null +++ b/test/SourceKit/CodeComplete/issue-80985.swift @@ -0,0 +1,13 @@ +// https://github.com/swiftlang/swift/issues/80985 +struct S { + func foo(_ fn: (T) -> U) -> S { fatalError() } +} + +func foo(xs: S<(Int, Int)>) { + _ = { + let y = xs + .foo{ $1 } + .foo{ $0 } + // RUN: %sourcekitd-test -req=complete -pos=%(line-1):11 %s -- %s + } +}