diff --git a/lib/SILGen/SILGenThunk.cpp b/lib/SILGen/SILGenThunk.cpp index 31b7e4398444a..5476dc755b695 100644 --- a/lib/SILGen/SILGenThunk.cpp +++ b/lib/SILGen/SILGenThunk.cpp @@ -217,6 +217,17 @@ SILFunction *SILGenModule::getOrCreateForeignAsyncCompletionHandlerImplFunction( } return maybeCompletionHandlerOrigTy.getValue(); }(); + + // Bridge the block type, so that if it is formally expressed in terms of + // bridged Swift types, we still lower the parameters to their ultimate + // ObjC types. + completionHandlerOrigTy = Types + .getBridgedFunctionType(AbstractionPattern(origFormalType.getGenericSignatureOrNull(), + completionHandlerOrigTy), + completionHandlerOrigTy, + Bridgeability::Full, + SILFunctionTypeRepresentation::Block); + auto blockParams = completionHandlerOrigTy.getParams(); // Build up the implementation function type, which matches the diff --git a/test/SILGen/objc_async_defined_in_swift_any.swift b/test/SILGen/objc_async_defined_in_swift_any.swift new file mode 100644 index 0000000000000..b226cf147ced2 --- /dev/null +++ b/test/SILGen/objc_async_defined_in_swift_any.swift @@ -0,0 +1,22 @@ +// RUN: %target-swift-emit-silgen(mock-sdk: %clang-importer-sdk) -disable-availability-checking -verify %s +// REQUIRES: concurrency +// REQUIRES: objc_interop + +import Foundation +@objc public protocol TAService { + func removeKey() async -> Any +} + +class FakeService : TAService { + func removeKey() async -> Any { + return "" + } +} + +class FakeClassHolder { + var service : TAService = FakeService() + + func removeKey(_ key: String) async { + _ = await self.service.removeKey() + } +}