Skip to content
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

Add initial Java annotations for Kotlin sugar proposal #111

Closed

Conversation

JakeWharton
Copy link

No description provided.


## Feedback

Discussion of this proposal is held in [this issue](TODO).
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO should be changed to #110

A Java library can do one of two things to go farther with its support:

1. Publish Kotlin extensions inside their library or as a sibling artifact.
2. Rewrite their public API (or the entire library in Kotlin).
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only "or the entire library" should be enclosed in the parentheses.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how this made it in. I thought I fixed it long ago... Thanks! Updated.

* Two extension annotations or one?
  * @extension(type=FUNCTION/PROPERTY)
    * Okay, except when you add the name into this annotation the declaration site becomes very verbose.
  * @extension + inferred from name
    * Name doesn’t always match intent to be a property
  * @ExtensionFunction or @ExtensionProperty
    * Two annotations
    * Bean prefix removal only applies to one

* Extension on method or on first parameter (receiver)
  * Method
  * Parameter
    * Like C#
    * Can be used on parameters which aren’t the first

* Name inside parameter or separate annotation
  * @ExtensionFunction(“name”)
  * @ExtensionFunction @name(“name”)
    * @name can be re-used for parameter names
    * Lets @name be used places it isn’t desired
    * Lets @name be used without @ExtensionFunction which we don’t like

Outcome:
 * When the name is combined with the annotation it makes more sense to have two annotations so you don’t have to supply name.

* Two default value annotations or one with null literal
  * @DefaultValue(“null”)
    * Ambiguous between “null” string or null reference
  * @defaultnull or @DefaultValue(“0”)
    * Explicit, no edge cases
    * Default for collections?
    * What about collection types we don’t know about?
  * Expressions in a default?
    * No time to discuss
  * @ParameterName
    * No time to discuss

Outcome:
* No changes. Need to revisit.

1. Rename @KtName to @ParameterName, scope only to parameters
2. Add name property to @ExtensionFunction and @ExtensionProperty
@elizarov
Copy link
Contributor

#110 (comment)

@elizarov elizarov closed this Dec 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants