mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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
|
||||
|
||||
22
test/SILGen/objc_async_defined_in_swift_any.swift
Normal file
22
test/SILGen/objc_async_defined_in_swift_any.swift
Normal 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()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user