From f5f079e49aefde5e71e9661e1b58f0e2963654dc Mon Sep 17 00:00:00 2001 From: "Aleksei.Cherepanov" Date: Wed, 23 Apr 2025 12:20:20 +0200 Subject: [PATCH] [JPS] Track changes of `PurelyImplements` annotation in Kotlin JPS incremental rules #KT-75460 Fixed GitOrigin-RevId: a1d7fb49ba94db1493d8a3604711d95a1c8c0be5 --- .../KotlinJvmDifferentiateStrategy.java | 10 +++++++++ .../SmartList.java | 22 +++++++++++++++++++ .../SmartList.java.new | 22 +++++++++++++++++++ .../TestClass.kt | 5 +++++ .../addPurelyImplementsAnnotation/build.log | 21 ++++++++++++++++++ .../IncrementalK2JvmJpsTestGenerated.java | 5 +++++ 6 files changed, 85 insertions(+) create mode 100644 plugins/kotlin/jps/graphImplementationTests/testData/incremental/withJava/javaUsedInKotlin/addPurelyImplementsAnnotation/SmartList.java create mode 100644 plugins/kotlin/jps/graphImplementationTests/testData/incremental/withJava/javaUsedInKotlin/addPurelyImplementsAnnotation/SmartList.java.new create mode 100644 plugins/kotlin/jps/graphImplementationTests/testData/incremental/withJava/javaUsedInKotlin/addPurelyImplementsAnnotation/TestClass.kt create mode 100644 plugins/kotlin/jps/graphImplementationTests/testData/incremental/withJava/javaUsedInKotlin/addPurelyImplementsAnnotation/build.log diff --git a/jps/jps-builders/src/org/jetbrains/jps/dependency/kotlin/KotlinJvmDifferentiateStrategy.java b/jps/jps-builders/src/org/jetbrains/jps/dependency/kotlin/KotlinJvmDifferentiateStrategy.java index 47a017d2866c..d2bb479b95bc 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/dependency/kotlin/KotlinJvmDifferentiateStrategy.java +++ b/jps/jps-builders/src/org/jetbrains/jps/dependency/kotlin/KotlinJvmDifferentiateStrategy.java @@ -71,6 +71,16 @@ public final class KotlinJvmDifferentiateStrategy extends JvmDifferentiateStrate new TypeRepr.ClassType("kotlin/Deprecated"), new TypeRepr.ClassType("kotlin/DeprecatedSinceKotlin") ) + ), + + AnnotationGroup.of( + "Kotlin JVM specific annotations", + EnumSet.of(AnnotationGroup.AnnTarget.type), + EnumSet.of(AnnotationGroup.AffectionKind.added, AnnotationGroup.AffectionKind.changed), + EnumSet.of(AnnotationGroup.AffectionScope.usages), + Set.of( + new TypeRepr.ClassType("kotlin/jvm/PurelyImplements") + ) ) ); diff --git a/plugins/kotlin/jps/graphImplementationTests/testData/incremental/withJava/javaUsedInKotlin/addPurelyImplementsAnnotation/SmartList.java b/plugins/kotlin/jps/graphImplementationTests/testData/incremental/withJava/javaUsedInKotlin/addPurelyImplementsAnnotation/SmartList.java new file mode 100644 index 000000000000..e19f100ee3bf --- /dev/null +++ b/plugins/kotlin/jps/graphImplementationTests/testData/incremental/withJava/javaUsedInKotlin/addPurelyImplementsAnnotation/SmartList.java @@ -0,0 +1,22 @@ +import java.util.AbstractList; +import kotlin.jvm.PurelyImplements; + +//@PurelyImplements("kotlin.collections.MutableList") +public class SmartList extends AbstractList { + + + @Override + public boolean add(E e) { + return true; + } + + @Override + public E get(int index) { + return null; + } + + @Override + public int size() { + return 0; + } +} \ No newline at end of file diff --git a/plugins/kotlin/jps/graphImplementationTests/testData/incremental/withJava/javaUsedInKotlin/addPurelyImplementsAnnotation/SmartList.java.new b/plugins/kotlin/jps/graphImplementationTests/testData/incremental/withJava/javaUsedInKotlin/addPurelyImplementsAnnotation/SmartList.java.new new file mode 100644 index 000000000000..51b97b1ffaf2 --- /dev/null +++ b/plugins/kotlin/jps/graphImplementationTests/testData/incremental/withJava/javaUsedInKotlin/addPurelyImplementsAnnotation/SmartList.java.new @@ -0,0 +1,22 @@ +import java.util.AbstractList; +import kotlin.jvm.PurelyImplements; + +@PurelyImplements("kotlin.collections.MutableList") +public class SmartList extends AbstractList { + + + @Override + public boolean add(E e) { + return true; + } + + @Override + public E get(int index) { + return null; + } + + @Override + public int size() { + return 0; + } +} \ No newline at end of file diff --git a/plugins/kotlin/jps/graphImplementationTests/testData/incremental/withJava/javaUsedInKotlin/addPurelyImplementsAnnotation/TestClass.kt b/plugins/kotlin/jps/graphImplementationTests/testData/incremental/withJava/javaUsedInKotlin/addPurelyImplementsAnnotation/TestClass.kt new file mode 100644 index 000000000000..199e41a6da0e --- /dev/null +++ b/plugins/kotlin/jps/graphImplementationTests/testData/incremental/withJava/javaUsedInKotlin/addPurelyImplementsAnnotation/TestClass.kt @@ -0,0 +1,5 @@ + +fun main() { + val result = SmartList() + result.add(null) +} \ No newline at end of file diff --git a/plugins/kotlin/jps/graphImplementationTests/testData/incremental/withJava/javaUsedInKotlin/addPurelyImplementsAnnotation/build.log b/plugins/kotlin/jps/graphImplementationTests/testData/incremental/withJava/javaUsedInKotlin/addPurelyImplementsAnnotation/build.log new file mode 100644 index 000000000000..26b3cce508f6 --- /dev/null +++ b/plugins/kotlin/jps/graphImplementationTests/testData/incremental/withJava/javaUsedInKotlin/addPurelyImplementsAnnotation/build.log @@ -0,0 +1,21 @@ +================ Step #1 ================= + +Cleaning output files: + out/production/module/SmartList.class +End of files +Exit code: NOTHING_DONE +------------------------------------------ +Compiling files: + src/SmartList.java +End of files +Cleaning output files: + out/production/module/META-INF/module.kotlin_module + out/production/module/TestClassKt.class +End of files +Compiling files: + src/TestClass.kt +End of files +Exit code: ABORT +------------------------------------------ +COMPILATION FAILED +Null cannot be a value of a non-null type 'kotlin.String'. \ No newline at end of file diff --git a/plugins/kotlin/jps/graphImplementationTests/tests/org/jetbrains/kotlin/jpsGraph/test/IncrementalK2JvmJpsTestGenerated.java b/plugins/kotlin/jps/graphImplementationTests/tests/org/jetbrains/kotlin/jpsGraph/test/IncrementalK2JvmJpsTestGenerated.java index d210b3f10f44..0742419acfe1 100644 --- a/plugins/kotlin/jps/graphImplementationTests/tests/org/jetbrains/kotlin/jpsGraph/test/IncrementalK2JvmJpsTestGenerated.java +++ b/plugins/kotlin/jps/graphImplementationTests/tests/org/jetbrains/kotlin/jpsGraph/test/IncrementalK2JvmJpsTestGenerated.java @@ -1452,6 +1452,11 @@ public class IncrementalK2JvmJpsTestGenerated extends AbstractIncrementalK2JvmJp runTest("withJava/javaUsedInKotlin/addNullableAnnotation/"); } + @TestMetadata("addPurelyImplementsAnnotation") + public void testAddPurelyImplementsAnnotation() throws Exception { + runTest("withJava/javaUsedInKotlin/addPurelyImplementsAnnotation/"); + } + public void testAllFilesPresentInJavaUsedInKotlin() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("withJava/javaUsedInKotlin"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); }