Skip to content

Commit 95e92d5

Browse files
committed
SILGen: Set context generic params for bridging thunks.
So that we do the right thing with thunks for generic ObjC methods. Partially fixes rdar://problem/27869089.
1 parent 0219ecd commit 95e92d5

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

lib/SILGen/SILGenBridging.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,9 @@ void SILGenFunction::emitNativeToForeignThunk(SILDeclRef thunk) {
957957
SGM.M, SGM.M.getSwiftModule(), subs);
958958
SILType substSILTy = SILType::getPrimitiveObjectType(substTy);
959959

960+
// Use the same context generic params as the native entry point.
961+
F.setContextGenericParams(nativeInfo.ContextGenericParams);
962+
960963
auto loc = thunk.getAsRegularLocation();
961964
loc.markAutoGenerated();
962965
Scope scope(Cleanups, CleanupLocation::get(loc));
@@ -1116,6 +1119,9 @@ void SILGenFunction::emitForeignToNativeThunk(SILDeclRef thunk) {
11161119
auto nativeFnTy = F.getLoweredFunctionType();
11171120
assert(nativeFnTy == nativeCI.SILFnType);
11181121

1122+
// Use the same context generic params as the native entry point.
1123+
F.setContextGenericParams(nativeCI.ContextGenericParams);
1124+
11191125
// Find the foreign error convention and 'self' parameter index.
11201126
Optional<ForeignErrorConvention> foreignError;
11211127
if (nativeFnTy->hasErrorResult()) {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@import Foundation;
2+
3+
@interface Thingy<T>: NSObject
4+
5+
@end
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-silgen %s -import-objc-header %S/Inputs/objc_bridged_generic_conformance.h -verify
2+
// REQUIRES: objc_interop
3+
4+
protocol P { func test() }
5+
6+
extension Thingy: P {
7+
func test() {}
8+
}

0 commit comments

Comments
 (0)