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()

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ package org.jetbrains.annotations
3838
AnnotationTarget.CLASS,
3939
AnnotationTarget.FILE
4040
)
41-
annotation class CheckReturnValue
41+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
42+
expect annotation class CheckReturnValue()

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ package org.jetbrains.annotations
6868
AnnotationTarget.PROPERTY_SETTER,
6969
AnnotationTarget.CONSTRUCTOR
7070
)
71-
annotation class Contract(
71+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
72+
expect annotation class Contract(
7273
/**
7374
* Contains the contract clauses describing causal relations between call arguments and the returned value
7475
*/

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,14 @@ import org.intellij.lang.annotations.Language
2020
/**
2121
* @since 18.0.0
2222
*/
23-
class Debug private constructor() {
24-
/**
25-
* Prohibited default constructor.
26-
*/
27-
init {
28-
throw AssertionError("Debug should not be instantiated")
29-
}
30-
23+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
24+
expect class Debug private constructor() {
3125
/**
3226
* Allows to change the presentation of an object in debuggers
3327
*/
3428
@Target(AnnotationTarget.CLASS)
3529
@Retention(AnnotationRetention.BINARY)
30+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
3631
annotation class Renderer(
3732
/**
3833
* Expression to be evaluated and used as the textual representation of the object.<br></br>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ package org.jetbrains.annotations
2828
@Retention(
2929
AnnotationRetention.BINARY
3030
)
31-
annotation class MustBeInvokedByOverriders
31+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
32+
expect annotation class MustBeInvokedByOverriders()

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ package org.jetbrains.annotations
4949
AnnotationTarget.TYPE,
5050
AnnotationTarget.FILE
5151
)
52-
annotation class Nls(val capitalization: Capitalization = Capitalization.NotSpecified) {
52+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
53+
expect annotation class Nls(val capitalization: Capitalization = Capitalization.NotSpecified) {
54+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
5355
enum class Capitalization {
5456
NotSpecified,
5557

multiplatform-annotations/src/commonMain/kotlin/org/jetbrains/annotations/NonBlocking.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 NonBlocking
40+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
41+
expect annotation class NonBlocking()

multiplatform-annotations/src/commonMain/kotlin/org/jetbrains/annotations/NonBlockingExecutor.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 NonBlockingExecutor
68+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
69+
expect annotation class NonBlockingExecutor()

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,5 @@ package org.jetbrains.annotations
7070
AnnotationTarget.TYPE,
7171
AnnotationTarget.FILE
7272
)
73-
annotation class NonNls
73+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
74+
expect annotation class NonNls()

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ package org.jetbrains.annotations
3030
AnnotationTarget.FIELD,
3131
AnnotationTarget.TYPE,
3232
)
33-
annotation class PropertyKey(
33+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
34+
expect annotation class PropertyKey(
3435
/**
3536
* The full-qualified name of the resource bundle in which the property keys must
3637
* be present. Consists of a full-qualified name of the package corresponding to the

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ package org.jetbrains.annotations
3030
@MustBeDocumented
3131
@Retention(AnnotationRetention.BINARY)
3232
@Target(AnnotationTarget.TYPE)
33-
annotation class Range(
33+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
34+
expect annotation class Range(
3435
/**
3536
* @return minimal allowed value (inclusive)
3637
*/

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ package org.jetbrains.annotations
3838
AnnotationTarget.FIELD,
3939
AnnotationTarget.CLASS
4040
)
41-
annotation class TestOnly
41+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
42+
expect annotation class TestOnly()

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ package org.jetbrains.annotations
3030
@MustBeDocumented
3131
@Retention(AnnotationRetention.BINARY)
3232
@Target(AnnotationTarget.TYPE)
33-
annotation class Unmodifiable
33+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
34+
expect annotation class Unmodifiable()

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,5 @@ package org.jetbrains.annotations
4444
AnnotationTarget.FIELD,
4545
AnnotationTarget.CLASS
4646
)
47-
annotation class VisibleForTesting
47+
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
48+
expect annotation class VisibleForTesting()
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright 2000-2021 JetBrains s.r.o.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.intellij.lang.annotations
17+
18+
@Pattern("\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*")
19+
actual annotation class Identifier

0 commit comments

Comments
 (0)