I was hoping there'd be a way to add a function to...
# android
y
I was hoping there'd be a way to add a function to an annotation that would provide hints to the type inference (it could be done something more than just nulls), bare with me on this, I know it's crude:
Copy code
interface PropertyTypeOverride<T> {
  /**
   * @param owningObject The object owning the property (if any)
   * @return The new type (null if no change)
   */
  fun override(owningObject: T?): KType<*>?
}
class Response(
    @DynamicType(PropertyTypeOverride {res: Response -> if (res.isSuccess()) Data::class.createType.withNullability(false) else null })
    val body: Data? = null)