I don't know Swift, but it looks like you're talking about a ‘self type’ — which represents the type of the class implementing the interface.
Unfortunately, Kotlin doesn't have self types. (See here for a very long-lasting discussion on the prospects of it being added.)
The usual workaround in Kotlin (and Java) is to make the interface generic, and give the implementing class as a type parameter. (I don't think there's a specific name for this pattern, but the equivalent in C++ is known as the curiously-recurring template pattern.)
However, the method in question is static, and so that pattern doesn't apply directly.
What you have there looks like a factory, and there are several ways that could be implemented — I'm not sure which best matches your Swift code, but each one can use generics. You could have a factory class, with one instance for each type of Parseable that you want to create; in that case, the factory class could have a type parameter. Alternatively, you might have a singleton factory object, or a companion object, or a top-level factory function; in those cases, the function itself can be generic.
Here's what factory function might look like:
fun <P : Parseable> parse(json: JSON): P {
// Code that returns a value of type P
}
(In practice, you'd probably find you'd need access to some of the details of P, which aren't normally available at runtime due to type erasure. But you can work around that by making P reified
— which also needs the function to be inline
.)
Depending on the context, the caller might need to specify the type, e.g.:
val result = parse<MyParseable>(json)
(The IDE will usually let you know if you need to provide the type, or whether the compiler can infer it.)