wrapper to call a generic when my object is an instance of a generic interface where the generic types have been filled in?
Copy code
// Kotlin
interface UseCase<I, O> {
suspend fun execute(input: I): O
}
class FooUseCase: UseCase<Bar, Baz> {
override suspend fun execute(input: Bar): Baz {
return Baz()
}
}
//Swift: Somewhere in an ObservableObject
let fooUseCase: FooUseCase = KotlinDependencies.getFooUseCase()
// In some function
Task {
let bar = getBar()
let result = try await fooUseCase.execute(input: bar)
}
This itself does not produce a syntax error but if I try to wrap my usecase in the
skie
function there are some type inference errors.
Copy code
try await skie(fooUseCase).execute(input: bar // This leads to type inference errors
f
Filip Dolník
01/22/2024, 12:28 PM
The wrapper should not be used for methods that originate from generic interfaces - only generic classes. The reason is that interfaces in Obj-C loose the generics and therefore do not have the same problem as generic classes.