Skip to content

Commit 7bc931a

Browse files
committed
Make multiplatform expect/actual implicitly actualizing declarations with java classes on jvm
1 parent 42bb869 commit 7bc931a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1419
-55
lines changed

multiplatform-annotations/build.gradle.kts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import org.gradle.jvm.tasks.Jar
2+
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
23
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
34

45
plugins {
@@ -60,17 +61,21 @@ kotlin {
6061
compileOnly("org.jetbrains.kotlin:kotlin-stdlib")
6162
}
6263
}
64+
65+
val nonJvmMain by creating {}
66+
}
67+
68+
targets.onEach {
69+
if (it.platformType != KotlinPlatformType.jvm) {
70+
it.compilations.getByName("main").source(sourceSets.getByName("nonJvmMain"))
71+
}
6372
}
6473

65-
/**
66-
* @Nls contains enum class. Kotlin automatically generates
67-
* `.entries` method for every enum and adds @NotNull to it.
68-
* This disables `.entries` generation.
69-
*/
7074
targets.all {
7175
compilations.all {
7276
compilerOptions.configure {
73-
freeCompilerArgs.add("-XXLanguage:-EnumEntries")
77+
optIn.add("kotlin.ExperimentalMultiplatform")
78+
freeCompilerArgs.add("-Xexpect-actual-classes")
7479
}
7580
}
7681
}

multiplatform-annotations/src/commonMain/kotlin/org/intellij/lang/annotations/Identifier.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@
1616
package org.intellij.lang.annotations
1717

1818
@Pattern("\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*")
19-
annotation class Identifier
19+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
20+
expect annotation class Identifier()

multiplatform-annotations/src/commonMain/kotlin/org/intellij/lang/annotations/Language.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ import org.jetbrains.annotations.NonNls
4747
AnnotationTarget.LOCAL_VARIABLE,
4848
AnnotationTarget.ANNOTATION_CLASS
4949
)
50-
annotation class Language(
50+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
51+
expect annotation class Language(
5152
/**
5253
* Language name like "JAVA", "HTML", "XML", "RegExp", etc.
5354
* The complete list of supported languages is not specified. However, at least the following languages should be

multiplatform-annotations/src/commonMain/kotlin/org/intellij/lang/annotations/Pattern.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ import org.jetbrains.annotations.NonNls
4949
AnnotationTarget.LOCAL_VARIABLE,
5050
AnnotationTarget.ANNOTATION_CLASS
5151
)
52-
annotation class Pattern(
52+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
53+
expect annotation class Pattern(
5354
/**
5455
* A regular expression that matches all the valid string literals that assigned to the annotated variables,
5556
* passed as arguments to the annotated parameters, or returned from the annotated methods.

multiplatform-annotations/src/commonMain/kotlin/org/intellij/lang/annotations/RegExp.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ import org.jetbrains.annotations.NonNls
3838
AnnotationTarget.ANNOTATION_CLASS
3939
)
4040
@Language("RegExp")
41-
annotation class RegExp(
41+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
42+
expect annotation class RegExp(
4243
/**
4344
* A constant prefix that is assumed to be implicitly added before the regular expression.
4445
*/

multiplatform-annotations/src/commonMain/kotlin/org/intellij/lang/annotations/Subst.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,5 @@ package org.intellij.lang.annotations
4949
AnnotationTarget.LOCAL_VARIABLE,
5050
AnnotationTarget.VALUE_PARAMETER
5151
)
52-
annotation class Subst(val value: String)
52+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
53+
expect annotation class Subst(val value: String)

multiplatform-annotations/src/commonMain/kotlin/org/jetbrains/annotations/ApiStatus.kt

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,8 @@ package org.jetbrains.annotations
2020
*
2121
* @since 18.0.0
2222
*/
23-
class ApiStatus private constructor() {
24-
/**
25-
* Prohibited default constructor.
26-
*/
27-
init {
28-
throw AssertionError("ApiStatus should not be instantiated")
29-
}
30-
23+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
24+
expect class ApiStatus private constructor() {
3125
/**
3226
*
3327
* Indicates that a public API of the annotated element (class, method or field) is not in stable state yet. It may be renamed, changed or
@@ -60,7 +54,8 @@ class ApiStatus private constructor() {
6054
AnnotationTarget.FIELD,
6155
AnnotationTarget.FILE
6256
)
63-
annotation class Experimental
57+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
58+
annotation class Experimental()
6459

6560
/**
6661
* Indicates that the annotated element (class, method, field, etc) must not be considered as a public API. It's made visible to allow
@@ -89,7 +84,8 @@ class ApiStatus private constructor() {
8984
AnnotationTarget.FIELD,
9085
AnnotationTarget.FILE
9186
)
92-
annotation class Internal
87+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
88+
annotation class Internal()
9389

9490
/**
9591
*
@@ -111,6 +107,7 @@ class ApiStatus private constructor() {
111107
AnnotationTarget.FIELD,
112108
AnnotationTarget.FILE
113109
)
110+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
114111
annotation class Obsolete(
115112
/**
116113
* Specifies in which version the API became obsolete.
@@ -139,6 +136,7 @@ class ApiStatus private constructor() {
139136
AnnotationTarget.FIELD,
140137
AnnotationTarget.FILE
141138
)
139+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
142140
annotation class ScheduledForRemoval(
143141
/**
144142
* Specifies in which version the API will be removed.
@@ -165,6 +163,7 @@ class ApiStatus private constructor() {
165163
AnnotationTarget.FIELD,
166164
AnnotationTarget.FILE
167165
)
166+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
168167
annotation class AvailableSince(
169168
/**
170169
* Specifies a version where the annotation API firstly appeared.
@@ -194,7 +193,8 @@ class ApiStatus private constructor() {
194193
AnnotationTarget.PROPERTY_GETTER,
195194
AnnotationTarget.PROPERTY_SETTER
196195
)
197-
annotation class NonExtendable
196+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
197+
annotation class NonExtendable()
198198

199199
/**
200200
*
@@ -219,5 +219,6 @@ class ApiStatus private constructor() {
219219
AnnotationTarget.PROPERTY_GETTER,
220220
AnnotationTarget.PROPERTY_SETTER
221221
)
222-
annotation class OverrideOnly
222+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
223+
annotation class OverrideOnly()
223224
}

multiplatform-annotations/src/commonMain/kotlin/org/jetbrains/annotations/Async.kt

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,8 @@ package org.jetbrains.annotations
2121
*
2222
* @author egor
2323
*/
24-
class Async private constructor() {
25-
/**
26-
* Prohibited default constructor.
27-
*/
28-
init {
29-
throw AssertionError("Async should not be instantiated")
30-
}
31-
24+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
25+
expect class Async private constructor() {
3226
/**
3327
* Indicates that the marked method schedules async computation.
3428
* Scheduled object is either `this`, or the annotated parameter value.
@@ -41,7 +35,8 @@ class Async private constructor() {
4135
AnnotationTarget.CONSTRUCTOR,
4236
AnnotationTarget.VALUE_PARAMETER
4337
)
44-
annotation class Schedule
38+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
39+
annotation class Schedule()
4540

4641
/**
4742
* Indicates that the marked method executes async computation.
@@ -56,5 +51,6 @@ class Async private constructor() {
5651
AnnotationTarget.CONSTRUCTOR,
5752
AnnotationTarget.VALUE_PARAMETER
5853
)
59-
annotation class Execute
54+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
55+
annotation class Execute()
6056
}

multiplatform-annotations/src/commonMain/kotlin/org/jetbrains/annotations/Blocking.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ package org.jetbrains.annotations
3737
AnnotationTarget.CONSTRUCTOR,
3838
AnnotationTarget.CLASS
3939
)
40-
annotation class Blocking
40+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
41+
expect annotation class Blocking()

multiplatform-annotations/src/commonMain/kotlin/org/jetbrains/annotations/BlockingExecutor.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,5 @@ package org.jetbrains.annotations
6565
@MustBeDocumented
6666
@Retention(AnnotationRetention.BINARY)
6767
@Target(AnnotationTarget.CLASS, AnnotationTarget.TYPE)
68-
annotation class BlockingExecutor
68+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
69+
expect annotation class BlockingExecutor()

0 commit comments

Comments
 (0)