-
Notifications
You must be signed in to change notification settings - Fork 362
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
Improvements to annotation use-site targets on properties #402
Comments
The link with the text "defaulting rule" goes to |
I like this idea. It's how I expected annotations to behave. As additional examples, there is a lot of code in the wild that looks like: @Serializable
class Foo(
@ObjectId
@SerialName("_id")
val id: String
) I wonder though if it will break some frameworks. Issues in annotation-based frameworks are in general difficult to detect. What if there exists a framework that behaves differently based on whether the annotation is specified on the constructor parameter or on both the constructor parameter and fields. Would there be a way to detect this? I doubt it, so the best we can do is migrate slowly and hope users detect issues easily? |
This is great, I've definitely shot myself in the foot with the wrong target before.
This seems overly restrictive. IMO it's obvious that Was |
This is why we are giving some interim period with a warning, so that people can reflect on their use-site. Actually, in many cases we think this may reveal that some annotation is not applied in the way they were thinking (especially when using validation frameworks). |
Unfortunately this doesn't seem to be so clear cut. During the design different people came up with different answers to what
For me, the key point here is that Kotlin does not work that way. It has never applied annotations in properties to the accessors, for example. We don't want to change completely how Kotlin handles annotations, only tweak one of the rules that we think causes a lot of confusion. |
all
meta-target
This is an issue to discuss changing the defaulting rule for annotations and the new
all
meta-target. The full text of the proposal can be found here.The text was updated successfully, but these errors were encountered: