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
* update: update JVM target bytecode version 24
* update: updates for REPL in Kotlin 2.2.0
* Adding infromation to docs about JVM default method generation (#4867)
* feat: adding infromation to docs about JVM default method generation
* implementing review comments
* implementing review comments for java to kotlin interop
* implementing comments from TWr review
* update: adding information about new context-sensitive resolution (#4865)
* update: adding information about new context-sensitive resolution to documentation
* implementing review comments
* implementing TWr review comments
* feat: stable non-local jumps (#4875)
* feat: add section for read write annotations kotlin metadata (#4870)
* feat: add note about experimental annotation support in Kotlin metadata
* adding new section to increase visibility in docs
* implementing comments from TWr review
* update: ant warning (#4882)
* update: new annotations defaulting rule and the new `all` meta-target (#4874)
* feat: new compiler warning management (#4876)
* feat: update JVM records for 2.2.0
* update: language updates for 2.2.0 release (#4873)
* update: language updates for 2.2.0 release
This PR contains doc updates about context parameters, guard conditions, and nested type aliases.
* Daniel review
* chore: fix typo
Co-authored-by: Dániel Csorba <[email protected]>
* add clarification about context receivers
* Removing paragraph about context receivers
---------
Co-authored-by: Dániel Csorba <[email protected]>
* feat: add @JvmExposeBoxed annotation for 2.2.0
* update: Windows support in Native (#4879)
* feat: add build tools API
* feat: add BCV for KGP
* chore: fix What's new version reference
* update: update the statuses of language features for Kotlin 2.2.0 (#4901)
* Update the statuses of language features for Kotlin 2.2
* fix: fix the status for Kotlin statics
---------
Co-authored-by: Andrey Polyakov <[email protected]>
* feat: add migration text from kotlinOptions{}
* feat: add 2.2.0 compatibility guide document (#4877)
* feat: first language tickets for compatibility guide
This update includes the first batch of language tickets to be included in the 2.2.0 compatibility guide
* updating compatibility guide draft with language and stdlib tickets
* update: kotlin-android-extensions deprecation
* adding build tools features to the compatibility guide
* implementing build tools review comments
* implementing additional small comment
* Kotlin scripting update
* feat: multiplatform compatibility issues
* chore: header
* fix: review suggestions
Co-authored-by: Sarah Haggarty <[email protected]>
* fix: review suggestions
* implementing TWr review comments
---------
Co-authored-by: Danil.Pavlov <[email protected]>
Co-authored-by: Sarah Haggarty <[email protected]>
Co-authored-by: Sarah Haggarty <[email protected]>
* feat: new features in memory manager (#4880)
* feat: Kotlin 2.2.0 release details and What's new (#4897)
* Kotlin 2.2.0 release details and What's new
* Adding What's new 2.2.0
* chore: resolve conflict in kr.tree
* chore: fix links
* Andrey review
* feat: legacy DCE deprecation (#4885)
---------
Co-authored-by: Sarah Haggarty <[email protected]>
Co-authored-by: Dániel Csorba <[email protected]>
Co-authored-by: Danil Pavlov <[email protected]>
Co-authored-by: Aleksey Zamulla <[email protected]>
Co-authored-by: Mikhail Zarechenskiy <[email protected]>
Co-authored-by: Andrey Polyakov <[email protected]>
Co-authored-by: Sarah Haggarty <[email protected]>
Annotations are means of attaching metadata to code. To declare an annotation, put the `annotation` modifier in front of a class:
3
+
Annotations are a means of attaching metadata to code. To declare an annotation, put the `annotation` modifier in front of a class:
4
4
5
5
```kotlin
6
6
annotationclassFancy
@@ -137,14 +137,14 @@ val f = @Suspendable { Fiber.sleep(10) }
137
137
138
138
## Annotation use-site targets
139
139
140
-
When you're annotating a property or a primary constructor parameter, there are multiple Java elements which are
140
+
When you're annotating a property or a primary constructor parameter, there are multiple Java elements that are
141
141
generated from the corresponding Kotlin element, and therefore multiple possible locations for the annotation in
142
142
the generated Java bytecode. To specify how exactly the annotation should be generated, use the following syntax:
143
143
144
144
```kotlin
145
-
classExample(@field:Ann val foo, // annotate Java field
146
-
@get:Ann val bar, // annotate Java getter
147
-
@param:Ann val quux) // annotate Java constructor parameter
145
+
classExample(@field:Ann val foo, // annotate only the Java field
146
+
@get:Ann val bar, // annotate only the Java getter
147
+
@param:Ann val quux) // annotate only the Java constructor parameter
148
148
```
149
149
150
150
The same syntax can be used to annotate the entire file. To do this, put an annotation with the target `file` at
@@ -157,7 +157,7 @@ package org.jetbrains.demo
157
157
```
158
158
159
159
If you have multiple annotations with the same target, you can avoid repeating the target by adding brackets after the
160
-
target and putting all the annotations inside the brackets:
160
+
target and putting all the annotations inside the brackets (except for the `all` meta-target):
161
161
162
162
```kotlin
163
163
classExample {
@@ -169,27 +169,168 @@ class Example {
169
169
The full list of supported use-site targets is:
170
170
171
171
*`file`
172
-
*`property` (annotations with this target are not visible to Java)
173
172
*`field`
173
+
*`property` (annotations with this target are not visible to Java)
174
174
*`get` (property getter)
175
175
*`set` (property setter)
176
+
*`all` (an experimental meta-target for properties, see [below](#all-meta-target) for its purpose and usage)
176
177
*`receiver` (receiver parameter of an extension function or property)
178
+
179
+
To annotate the receiver parameter of an extension function, use the following syntax:
180
+
181
+
```kotlin
182
+
fun @receiver:Fancy String.myExtension() { ... }
183
+
```
184
+
177
185
* `param` (constructor parameter)
178
186
* `setparam` (property setter parameter)
179
187
* `delegate` (the field storing the delegate instance for a delegated property)
180
188
181
-
To annotate the receiver parameter of an extension function, use the following syntax:
189
+
### Defaultswhen no use-site targets are specified
190
+
191
+
If you don't specify a use-site target, the target is chosen according to the `@Target` annotation of the annotation
192
+
being used.
193
+
If there are multiple applicable targets, the first applicable target from the following list is used:
194
+
195
+
* `param`
196
+
* `property`
197
+
* `field`
198
+
199
+
Let's use the [`@Email` annotation from JakartaBeanValidation](https://jakarta.ee/specifications/bean-validation/3.0/apidocs/jakarta/validation/constraints/email):
The `all` target makes it easier to apply the same annotationnot only to the parameter and the property or field, but also to the corresponding getter and setter.
269
+
270
+
Specifically, the annotation marked with `all` is propagated, if applicable:
271
+
272
+
*To the constructor parameter (`param`) if the property is defined in the primary constructor.
273
+
*To the property itself (`property`).
274
+
*To the backing field (`field`) if the property has one.
275
+
*To the getter (`get`).
276
+
*To the setter parameter (`setparam`) if the property is defined as `var`.
277
+
*To the Java-only target `RECORD_COMPONENT` if the classhas the `@JvmRecord` annotation.
278
+
279
+
Let's use the [`@Email` annotation from Jakarta Bean Validation](https://jakarta.ee/specifications/bean-validation/3.0/apidocs/jakarta/validation/constraints/email),
0 commit comments