Skip to content

Commit 1cb1546

Browse files
authored
Merge pull request #59137 from jckarter/objc-async-defined-in-swift-type-bridge
SILGen: Use ObjC types to lower async completion handler arguments.
2 parents d20b9a8 + a596863 commit 1cb1546

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

lib/SILGen/SILGenThunk.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,17 @@ SILFunction *SILGenModule::getOrCreateForeignAsyncCompletionHandlerImplFunction(
217217
}
218218
return maybeCompletionHandlerOrigTy.getValue();
219219
}();
220+
221+
// Bridge the block type, so that if it is formally expressed in terms of
222+
// bridged Swift types, we still lower the parameters to their ultimate
223+
// ObjC types.
224+
completionHandlerOrigTy = Types
225+
.getBridgedFunctionType(AbstractionPattern(origFormalType.getGenericSignatureOrNull(),
226+
completionHandlerOrigTy),
227+
completionHandlerOrigTy,
228+
Bridgeability::Full,
229+
SILFunctionTypeRepresentation::Block);
230+
220231
auto blockParams = completionHandlerOrigTy.getParams();
221232

222233
// Build up the implementation function type, which matches the
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %target-swift-emit-silgen(mock-sdk: %clang-importer-sdk) -disable-availability-checking -verify %s
2+
// REQUIRES: concurrency
3+
// REQUIRES: objc_interop
4+
5+
import Foundation
6+
@objc public protocol TAService {
7+
func removeKey() async -> Any
8+
}
9+
10+
class FakeService : TAService {
11+
func removeKey() async -> Any {
12+
return ""
13+
}
14+
}
15+
16+
class FakeClassHolder {
17+
var service : TAService = FakeService()
18+
19+
func removeKey(_ key: String) async {
20+
_ = await self.service.removeKey()
21+
}
22+
}

0 commit comments

Comments
 (0)