You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Kotlin supports where clauses which can make complex type-constraints more readable. For example,
classGenericPerson<Self, Builder> where
Self:GenericPerson<Self, Builder>,
Builder:GenericPersonBuilder<Builder, Self>
classGenericPersonBuilder<Self, Built> where
Self:GenericPersonBuilder<Self, Built>,
Built:GenericPerson<Built, Self>
Describe the solution you'd like
It would be nice if KotlinPoet allowed generating APIs like that. I'm not sure what the best way to go about this is.
In general we are opposed to functionality which lets the user change the formatting of the output. I would be much more supportive of a simple rule that applies globally. We do similar things for when to wrap function parameters onto multiple lines, for example.
Fair enough. How about a rule like this?
Use the where clause if the type variables + bounds take up more than 80
chars && there’s at least a 50% reduction in length for the type variables
declaration when the bounds are removed.
Is your feature request related to a problem? Please describe.
Kotlin supports where clauses which can make complex type-constraints more readable. For example,
Describe the solution you'd like
It would be nice if KotlinPoet allowed generating APIs like that. I'm not sure what the best way to go about this is.
Perhaps,
TypeSpec.classBuilder("...").useWhereClauseForTypeConstraints(true).build()
?Describe alternatives you've considered
I'm just using the existing APIs to declare the type constraints inline for now.
Additional context
N/A
The text was updated successfully, but these errors were encountered: