Tijl
03/29/2021, 6:29 PMclass Foo<T> { // no upper bound
fun bar(baz: (T) -> Unit) {
}
}
@interface KNFFoo<T> : KNFBase // leads to T _Nullable as expected
- (void)barBaz:(void (^)(T _Nullable))baz __attribute__((swift_name("bar(baz:)")));
@end;
class Foo<T:Any> { // Upper bound of Any
fun bar(baz: (T) -> Unit) {
}
}
@interface KNFFoo<T> : KNFBase
- (void)barBaz:(void (^)(T))baz // leads to T as expected __attribute__((swift_name("bar(baz:)")));
@end;
class Foo<T> {
fun bar(baz: (T:Any) -> Unit) { // upperbound of Any just for the method
}
}
@interface KNFFoo<T> : KNFBase
- (void)barBaz:(void (^)(id))baz // <----- id not T? __attribute__((swift_name("bar(baz:)")));
Anyone a little more familiar than me know if my assumption this could be T instead of id is correct?Tijl
03/29/2021, 6:30 PMbasher
03/30/2021, 11:47 PMbasher
03/30/2021, 11:47 PMTijl
03/31/2021, 5:28 AMTijl
03/31/2021, 5:42 AMis
I had somewhere smart-casting the Any I was passing in my non-simplified code.Tijl
03/31/2021, 5:51 AMfun <T:Any>baz(t:T)
is accepted so I’ll test if that worksTijl
03/31/2021, 6:03 AMbasher
03/31/2021, 3:25 PMkpgalligan
03/31/2021, 3:26 PMrusshwolf
03/31/2021, 8:50 PMT
instead of Any
from Swift, you need to do class Foo<T: Any>
and fun baz(t: T)
. Only generic declarations on classes (rather than interfaces or functions) get exposed to Obj-C