The expected approach seems to be to drop to weak typing by reinterpreting the object as a function. The class can be given an inline extension operator invoke along these lines:
inline operator fun Express.invoke(): ExpressApp {
return this.unsafeCast<() -> ExpressApp>()()
}
Alternatively the receiver can be treated as the dynamic type:
inline operator fun Express.invoke(): ExpressApp {
return this.asDynamic()() as ExpressApp
}