-
Notifications
You must be signed in to change notification settings - Fork 279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow generating where clauses for complex type constraints #1494
Labels
Comments
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.
|
I was thinking:
|
Yep. That looks better :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: