Merge pull request #59137 from jckarter/objc-async-defined-in-swift-type-bridge

SILGen: Use ObjC types to lower async completion handler arguments.
This commit is contained in:
Joe Groff
2022-05-31 08:58:12 -07:00
committed by GitHub
2 changed files with 33 additions and 0 deletions

View File

@@ -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

View File

@@ -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()
}
}