diff --git a/analysis/analysis-api-standalone/src/org/jetbrains/kotlin/analysis/api/standalone/StandaloneAnalysisAPISession.kt b/analysis/analysis-api-standalone/src/org/jetbrains/kotlin/analysis/api/standalone/StandaloneAnalysisAPISession.kt index d4c1d6fce8c..fc23085d565 100644 --- a/analysis/analysis-api-standalone/src/org/jetbrains/kotlin/analysis/api/standalone/StandaloneAnalysisAPISession.kt +++ b/analysis/analysis-api-standalone/src/org/jetbrains/kotlin/analysis/api/standalone/StandaloneAnalysisAPISession.kt @@ -9,13 +9,16 @@ import com.intellij.core.CoreApplicationEnvironment import com.intellij.mock.MockProject import com.intellij.openapi.application.Application import com.intellij.openapi.project.Project +import com.intellij.psi.PsiFile import com.intellij.psi.search.GlobalSearchScope +import org.jetbrains.kotlin.analysis.project.structure.KtModule import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreProjectEnvironment import org.jetbrains.kotlin.load.kotlin.PackagePartProvider public class StandaloneAnalysisAPISession internal constructor( kotlinCoreProjectEnvironment: KotlinCoreProjectEnvironment, public val createPackagePartProvider: (GlobalSearchScope) -> PackagePartProvider, + modulesWithFilesProvider: () -> Map> ) { // TODO: better to limit exposure? Current usages are: addExtension, jarFileSystem public val coreApplicationEnvironment: CoreApplicationEnvironment = kotlinCoreProjectEnvironment.environment @@ -29,4 +32,6 @@ public class StandaloneAnalysisAPISession internal constructor( ReplaceWith("project") ) public val mockProject: MockProject = kotlinCoreProjectEnvironment.project + + public val modulesWithFiles: Map> by lazy(modulesWithFilesProvider) } \ No newline at end of file diff --git a/analysis/analysis-api-standalone/src/org/jetbrains/kotlin/analysis/api/standalone/StandaloneAnalysisAPISessionBuilder.kt b/analysis/analysis-api-standalone/src/org/jetbrains/kotlin/analysis/api/standalone/StandaloneAnalysisAPISessionBuilder.kt index c1b4ac9442c..8bb2abafb09 100644 --- a/analysis/analysis-api-standalone/src/org/jetbrains/kotlin/analysis/api/standalone/StandaloneAnalysisAPISessionBuilder.kt +++ b/analysis/analysis-api-standalone/src/org/jetbrains/kotlin/analysis/api/standalone/StandaloneAnalysisAPISessionBuilder.kt @@ -11,12 +11,14 @@ import com.intellij.openapi.application.Application import com.intellij.openapi.project.Project import com.intellij.openapi.util.Disposer import com.intellij.openapi.vfs.impl.jar.CoreJarFileSystem +import com.intellij.psi.PsiFile import com.intellij.psi.search.GlobalSearchScope import org.jetbrains.kotlin.analysis.api.KtAnalysisApiInternals import org.jetbrains.kotlin.analysis.api.standalone.base.project.structure.FirStandaloneServiceRegistrar import org.jetbrains.kotlin.analysis.api.standalone.base.project.structure.KtStaticProjectStructureProvider import org.jetbrains.kotlin.analysis.api.standalone.base.project.structure.StandaloneProjectFactory import org.jetbrains.kotlin.analysis.low.level.api.fir.api.services.FirSealedClassInheritorsProcessorFactory +import org.jetbrains.kotlin.analysis.low.level.api.fir.project.structure.JvmFirDeserializedSymbolProviderFactory import org.jetbrains.kotlin.analysis.project.structure.KtModuleScopeProvider import org.jetbrains.kotlin.analysis.project.structure.KtModuleScopeProviderImpl import org.jetbrains.kotlin.analysis.project.structure.builder.KtModuleProviderBuilder @@ -150,6 +152,8 @@ public class StandaloneAnalysisAPISessionBuilder( PackagePartProviderFactory::class.java, KotlinStaticPackagePartProviderFactory(packagePartProvider) ) + + registerService(JvmFirDeserializedSymbolProviderFactory::class.java, JvmFirDeserializedSymbolProviderFactory::class.java) } } @@ -208,7 +212,12 @@ public class StandaloneAnalysisAPISessionBuilder( return StandaloneAnalysisAPISession( kotlinCoreProjectEnvironment, createPackagePartProvider, - ) + ) { + projectStructureProvider.allSourceFiles + .asSequence() + .filterIsInstance() + .groupBy { projectStructureProvider.getModule(it.originalElement, null) } + } } } diff --git a/build.gradle.kts b/build.gradle.kts index eaf73ecc5fb..a1f75855d2a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -374,7 +374,8 @@ val projectsWithEnabledContextReceivers by extra { ":kotlin-lombok-compiler-plugin.k1", ":kotlinx-serialization-compiler-plugin.k2", ":plugins:parcelize:parcelize-compiler:parcelize.k2", - ":plugins:fir-plugin-prototype" + ":plugins:fir-plugin-prototype", + ":plugins:kapt4", ) } diff --git a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index cad7fb28e64..d0838684de8 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -38,6 +38,7 @@ import org.jetbrains.kotlin.kapt3.test.runners.AbstractClassFileToSourceStubConv import org.jetbrains.kotlin.kapt3.test.runners.AbstractIrClassFileToSourceStubConverterTest import org.jetbrains.kotlin.kapt3.test.runners.AbstractIrKotlinKaptContextTest import org.jetbrains.kotlin.kapt3.test.runners.AbstractKotlinKaptContextTest +import org.jetbrains.kotlin.kapt4.AbstractKotlinKapt4ContextTest import org.jetbrains.kotlin.lombok.* import org.jetbrains.kotlin.noarg.* import org.jetbrains.kotlin.parcelize.test.runners.* @@ -385,6 +386,11 @@ fun main(args: Array) { model("converter") } } + testGroup("plugins/kapt4/tests-gen", "plugins/kapt4/") { + testClass { + model("../kapt3/kapt3-compiler/testData/converter") + } + } testGroup("plugins/assign-plugin/tests-gen", "plugins/assign-plugin/testData") { testClass { diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/abstractEnum.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/abstractEnum.fir.txt new file mode 100644 index 00000000000..abfe2d1623d --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/abstractEnum.fir.txt @@ -0,0 +1,120 @@ +@kotlin.Metadata() +public enum E { + /*public static final*/ X /* = new E() */, + /*public static final*/ Y /* = new E() */; + + E() { + } + + public abstract void a(); + + public final void b() { + } + + @org.jetbrains.annotations.NotNull() + public static kotlin.enums.EnumEntries getEntries() { + return null; + } + + @kotlin.Metadata() + public static final class Obj { + @org.jetbrains.annotations.NotNull() + public static final E.Obj INSTANCE = null; + + private Obj() { + super(); + } + } + + @kotlin.Metadata() + public static final class NestedClass { + + public NestedClass() { + super(); + } + } +} + +//////////////////// + + +@kotlin.Metadata() +public enum E2 { + /*public static final*/ X /* = new E2() */, + /*public static final*/ Y /* = new E2() */; + + E2(int n) { + } + + E2(java.lang.String s) { + } + + public abstract void a(); + + @org.jetbrains.annotations.NotNull() + public static kotlin.enums.EnumEntries getEntries() { + return null; + } +} + +//////////////////// + + +@kotlin.Metadata() +public enum E3 { + /*public static final*/ X /* = new E3() */, + /*public static final*/ Y /* = new E3() */; + @org.jetbrains.annotations.NotNull() + private final java.lang.String a = null; + + E3(java.lang.String a) { + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getA() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public static kotlin.enums.EnumEntries getEntries() { + return null; + } +} + +//////////////////// + + +@kotlin.Metadata() +public enum E4 { + /*public static final*/ X /* = new E4() */; + @org.jetbrains.annotations.NotNull() + private final java.lang.String a = null; + private final int b = 0; + private final long c = 0L; + private final boolean d = false; + + E4(java.lang.String a, int b, long c, boolean d) { + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getA() { + return null; + } + + public final int getB() { + return 0; + } + + public final long getC() { + return 0L; + } + + public final boolean getD() { + return false; + } + + @org.jetbrains.annotations.NotNull() + public static kotlin.enums.EnumEntries getEntries() { + return null; + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/aliasedImports.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/aliasedImports.fir.txt new file mode 100644 index 00000000000..61ec5268403 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/aliasedImports.fir.txt @@ -0,0 +1,88 @@ +import a.b.ABC; + +@kotlin.Metadata() +public final class Test { + public Test.MyDate date; + public java.util.concurrent.TimeUnit timeUnit; + public a.b.ABC abc; + public bcd bcd; + + public Test() { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final Test.MyDate getDate() { + return null; + } + + public final void setDate(@org.jetbrains.annotations.NotNull() + Test.MyDate p0) { + } + + @org.jetbrains.annotations.NotNull() + public final java.util.concurrent.TimeUnit getTimeUnit() { + return null; + } + + public final void setTimeUnit(@org.jetbrains.annotations.NotNull() + java.util.concurrent.TimeUnit p0) { + } + + @org.jetbrains.annotations.NotNull() + public final a.b.ABC getAbc() { + return null; + } + + public final void setAbc(@org.jetbrains.annotations.NotNull() + a.b.ABC p0) { + } + + @org.jetbrains.annotations.NotNull() + public final bcd getBcd() { + return null; + } + + public final void setBcd(@org.jetbrains.annotations.NotNull() + bcd p0) { + } + + @kotlin.Metadata() + public static final class MyDate { + public Test.MyDate date2; + + public MyDate() { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final Test.MyDate getDate2() { + return null; + } + + public final void setDate2(@org.jetbrains.annotations.NotNull() + Test.MyDate p0) { + } + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class Test2 { + public java.util.Date date; + + public Test2() { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final java.util.Date getDate() { + return null; + } + + public final void setDate(@org.jetbrains.annotations.NotNull() + java.util.Date p0) { + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/aliasedImports.kt b/plugins/kapt3/kapt3-compiler/testData/converter/aliasedImports.kt index d868c4f13ab..d910a59feac 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/aliasedImports.kt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/aliasedImports.kt @@ -1,8 +1,7 @@ -// IGNORE_BACKEND: JVM_IR // CORRECT_ERROR_TYPES // NO_VALIDATION -@file:Suppress("ENUM_ENTRY_AS_TYPE", "UNRESOLVED_REFERENCE") +@file:Suppress("UNRESOLVED_REFERENCE") import java.util.Date as MyDate import java.util.concurrent.TimeUnit as MyTimeUnit import java.util.concurrent.TimeUnit.* @@ -14,7 +13,6 @@ import bcd as MyBCD class Test { lateinit var date: MyDate lateinit var timeUnit: MyTimeUnit - lateinit var microseconds: MyMicroseconds lateinit var abc: MyABC lateinit var bcd: MyBCD diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/aliasedImports.txt b/plugins/kapt3/kapt3-compiler/testData/converter/aliasedImports.txt index 1b67d8a629d..cc742ee79b9 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/aliasedImports.txt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/aliasedImports.txt @@ -6,7 +6,6 @@ import a.b.ABC; public final class Test { public Test.MyDate date; public java.util.concurrent.TimeUnit timeUnit; - public java.util.concurrent.TimeUnit microseconds; public a.b.ABC abc; public bcd bcd; @@ -32,15 +31,6 @@ public final class Test { java.util.concurrent.TimeUnit p0) { } - @org.jetbrains.annotations.NotNull() - public final java.util.concurrent.TimeUnit getMicroseconds() { - return null; - } - - public final void setMicroseconds(@org.jetbrains.annotations.NotNull() - java.util.concurrent.TimeUnit p0) { - } - @org.jetbrains.annotations.NotNull() public final a.b.ABC getAbc() { return null; diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/annotationWithFqNames.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/annotationWithFqNames.fir.txt new file mode 100644 index 00000000000..3b637ef222b --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/annotationWithFqNames.fir.txt @@ -0,0 +1,61 @@ +package lib; + +public @interface Anno { + + Class[] impls() default {}; +} + +//////////////////// + +package lib.impl; + +public class Impl { +} + +//////////////////// + +package test; + +@kotlin.Metadata() +@lib.Anno(impls = {lib.impl.Impl.class, ABC.class}) +public final class Bar { + + public Bar() { + super(); + } +} + +//////////////////// + +package test; + +@kotlin.Metadata() +@lib.Anno(impls = {lib.impl.Impl.class}) +public final class Boo { + + public Boo() { + super(); + } +} + +//////////////////// + +package test; + +@kotlin.Metadata() +@lib.Anno(impls = {lib.impl.Impl.class}) +public final class Foo { + + public Foo() { + super(); + } +} + +//////////////////// + +package test; + +@kotlin.Metadata() +@kotlin.Suppress(names = {"UNRESOLVED_REFERENCE", "ANNOTATION_ARGUMENT_MUST_BE_CONST", "NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION"}) +public final class TestKt { +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/annotations.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/annotations.fir.txt new file mode 100644 index 00000000000..f07eadbc56e --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/annotations.fir.txt @@ -0,0 +1,128 @@ +@kotlin.Metadata() +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface Anno1 { +} + +//////////////////// + + +@kotlin.Metadata() +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface Anno2 { + + public abstract int i() default 5; + + public abstract java.lang.String s() default "ABC"; + + public abstract int[] ii() default {1, 2, 3}; + + public abstract java.lang.String[] ss() default {"A", "B"}; + + public abstract Anno1 a(); + + public abstract Colors color() default Colors.BLACK; + + public abstract Colors[] colors() default {Colors.BLACK, Colors.WHITE}; + + public abstract java.lang.Class clazz(); + + public abstract java.lang.Class[] classes(); +} + +//////////////////// + + +@kotlin.Metadata() +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface Anno3 { + + public abstract java.lang.String value(); +} + +//////////////////// + + +@kotlin.Metadata() +public enum Colors { + /*public static final*/ WHITE /* = new Colors() */, + /*public static final*/ BLACK /* = new Colors() */; + + Colors() { + } + + @org.jetbrains.annotations.NotNull() + public static kotlin.enums.EnumEntries getEntries() { + return null; + } +} + +//////////////////// + + +@kotlin.Metadata() +public enum Enum1 { + /*public static final*/ BLACK /* = new Enum1() */, + @Anno1() + /*public static final*/ WHITE /* = new Enum1() */; + + Enum1() { + } + + @org.jetbrains.annotations.NotNull() + public static kotlin.enums.EnumEntries getEntries() { + return null; + } +} + +//////////////////// + + +@kotlin.Metadata() +@Anno1() +@Anno2(a = @Anno1(), clazz = TestAnno.class, classes = {TestAnno.class, Anno1.class}) +@Anno3(value = "value") +public final class TestAnno { + + public TestAnno() { + super(); + } +} + +//////////////////// + + +@kotlin.Metadata() +@Anno3(value = "value") +@Anno2(i = 6, s = "BCD", ii = {4, 5, 6}, ss = {"Z", "X"}, a = @Anno1(), color = Colors.WHITE, colors = {Colors.WHITE}, clazz = TestAnno.class, classes = {TestAnno.class, Anno1.class}) +public final class TestAnno2 { + @Anno3(value = "field") + @org.jetbrains.annotations.NotNull() + private java.lang.String b = "property initializer"; + + public TestAnno2() { + super(); + } + + @Anno1() + public final void a(@Anno3(value = "param-pam-pam") + @org.jetbrains.annotations.NotNull() + java.lang.String param) { + } + + @Anno3(value = "getter") + @org.jetbrains.annotations.NotNull() + public final java.lang.String getB() { + return null; + } + + @Anno3(value = "property") + @java.lang.Deprecated() + public static void getB$annotations() { + } + + @Anno3(value = "setter") + public final void setB(@Anno3(value = "setparam") + @org.jetbrains.annotations.NotNull() + java.lang.String p0) { + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/annotations2.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/annotations2.fir.txt new file mode 100644 index 00000000000..bb1f3926204 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/annotations2.fir.txt @@ -0,0 +1,114 @@ +package test; + +@kotlin.Metadata() +@Anno(value = "anno-class") +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface Anno { + + public abstract java.lang.String value(); +} + +//////////////////// + +package test; + +@kotlin.Metadata() +@kotlin.jvm.JvmName(name = "AnnotationsTest") +public final class AnnotationsTest { + + public AnnotationsTest() { + super(); + } + + @org.jetbrains.annotations.NotNull() + public static final java.lang.String getTopLevelVal(@Anno(value = "top-level-val-receiver") + int $this$topLevelVal) { + return null; + } + + @Anno(value = "top-level-val") + @java.lang.Deprecated() + public static void getTopLevelVal$annotations(int p0) { + } + + @Anno(value = "top-level-fun") + public static final void topLevelFun(@Anno(value = "top-level-fun-receiver") + @org.jetbrains.annotations.NotNull() + java.lang.String $this$topLevelFun) { + } +} + +//////////////////// + +package test; + +@kotlin.Metadata() +@Anno(value = "enum") +public enum Enum { + @Anno(value = "white") + /*public static final*/ WHITE /* = new Enum() */, + @Anno(value = "black") + /*public static final*/ BLACK /* = new Enum() */; + private final int x = 0; + + @Anno(value = "enum-constructor") + Enum(@Anno(value = "x") + int x) { + } + + public final int getX() { + return 0; + } + + @org.jetbrains.annotations.NotNull() + public static kotlin.enums.EnumEntries getEntries() { + return null; + } +} + +//////////////////// + +package test; + +@kotlin.Metadata() +@Anno(value = "clazz") +public abstract class Test { + @org.jetbrains.annotations.NotNull() + private java.lang.String v; + + @Anno(value = "test-constructor") + protected Test(@Anno(value = "v-param") + @org.jetbrains.annotations.NotNull() + java.lang.String v) { + super(); + } + + @Anno(value = "v-get") + @org.jetbrains.annotations.NotNull() + public final java.lang.String getV() { + return null; + } + + @Anno(value = "v-property") + @java.lang.Deprecated() + public static void getV$annotations() { + } + + @Anno(value = "v-set") + public final void setV(@Anno(value = "v-setparam") + @org.jetbrains.annotations.NotNull() + java.lang.String p0) { + } + + @Anno(value = "abstract-method") + @org.jetbrains.annotations.NotNull() + public abstract java.lang.String abstractMethod(); + + @org.jetbrains.annotations.NotNull() + public abstract java.lang.String getAbstractVal(); + + @Anno(value = "abstract-val") + @java.lang.Deprecated() + public static void getAbstractVal$annotations() { + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/annotations3.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/annotations3.fir.txt new file mode 100644 index 00000000000..6b68a4df568 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/annotations3.fir.txt @@ -0,0 +1,88 @@ +@kotlin.Metadata() +public final class B { + + public B() { + super(); + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class BParceler implements Parceler { + @org.jetbrains.annotations.NotNull() + public static final BParceler INSTANCE = null; + + private BParceler() { + super(); + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class C { + + public C() { + super(); + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class CParceler implements Parceler { + @org.jetbrains.annotations.NotNull() + public static final CParceler INSTANCE = null; + + private CParceler() { + super(); + } +} + +//////////////////// + + +@kotlin.Metadata() +public abstract interface Parceler { +} + +//////////////////// + + +@kotlin.Metadata() +@TypeParceler() +@TypeParceler() +public final class Test { + + public Test() { + super(); + } +} + +//////////////////// + + +@kotlin.Metadata() +@kotlin.annotation.Retention(value = kotlin.annotation.AnnotationRetention.SOURCE) +@kotlin.annotation.Repeatable() +@kotlin.annotation.Target(allowedTargets = {kotlin.annotation.AnnotationTarget.CLASS, kotlin.annotation.AnnotationTarget.PROPERTY}) +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.SOURCE) +@java.lang.annotation.Repeatable(value = TypeParceler.Container.class) +@java.lang.annotation.Target(value = {java.lang.annotation.ElementType.TYPE}) +public abstract @interface TypeParceler> { + + @kotlin.Metadata() + @kotlin.annotation.Retention(value = kotlin.annotation.AnnotationRetention.SOURCE) + @kotlin.annotation.Target(allowedTargets = {kotlin.annotation.AnnotationTarget.CLASS, kotlin.annotation.AnnotationTarget.PROPERTY}) + @kotlin.jvm.internal.RepeatableContainer() + @java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.SOURCE) + @java.lang.annotation.Target(value = {java.lang.annotation.ElementType.TYPE}) + public static abstract @interface Container { + + public abstract TypeParceler[] value(); + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/annotationsWithConstants.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/annotationsWithConstants.fir.txt new file mode 100644 index 00000000000..55ebec90c08 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/annotationsWithConstants.fir.txt @@ -0,0 +1,367 @@ +package app; + +@kotlin.Metadata() +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface Anno { + + public abstract boolean a1(); + + public abstract byte a2(); + + public abstract int a3(); + + public abstract short a4(); + + public abstract long a5(); + + public abstract char a6(); + + public abstract float a7(); + + public abstract double a8(); + + public abstract java.lang.String a9(); +} + +//////////////////// + +package app; + +public class B { + + public B() { + super(); + } + + public static class id { + + public id() { + super(); + } + public static final int textView = 200; + } + public static final boolean a1 = false; + public static final byte a2 = 1; + public static final int a3 = 2; + public static final short a4 = 3; + public static final long a5 = 4L; + public static final char a6 = '5'; + public static final float a7 = 6.0F; + public static final double a8 = 7.0; + public static final String a9 = "A"; +} + +//////////////////// + +package app; + +@kotlin.Metadata() +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface Bind { + + public abstract int id(); +} + +//////////////////// + +package app; + +@kotlin.Metadata() +@kotlin.annotation.Target(allowedTargets = {kotlin.annotation.AnnotationTarget.FIELD}) +@java.lang.annotation.Target(value = {java.lang.annotation.ElementType.FIELD}) +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface BindField { + + public abstract int id(); +} + +//////////////////// + +package app; + +@kotlin.Metadata() +public final class JJ { + @org.jetbrains.annotations.NotNull() + public static final app.JJ INSTANCE = null; + @org.jetbrains.annotations.NotNull() + private static final java.lang.String b = null; + + private JJ() { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getB() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String c() { + return null; + } +} + +//////////////////// + +package app; + +@kotlin.Metadata() +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface MultiValue { + + public abstract int[] ids(); +} + +//////////////////// + +package app; + +@kotlin.Metadata() +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface MultiValueByte { + + public abstract byte[] ids(); +} + +//////////////////// + +package app; + +@kotlin.Metadata() +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface MultiValueString { + + public abstract java.lang.String[] ids(); +} + +//////////////////// + +package app; + +@kotlin.Metadata() +public final class MyActivity { + @BindField(id = 100) + private final int a = 0; + @BindField(id = 100) + private final int b = 0; + @BindField(id = 100) + private final int c = 0; + @BindField(id = 100) + private final int d = 0; + @BindField(id = 100) + private final int e = 0; + @BindField(id = 200) + private final int f = 0; + public final int propA = 200; + private final int propB = 200; + private int propC = 200; + @kotlin.jvm.JvmField() + public final int propD = 200; + @kotlin.jvm.JvmField() + public int propE = 200; + private final int propF = 0; + + public MyActivity() { + super(); + } + + public final int getA() { + return 0; + } + + @Bind(id = 100) + @java.lang.Deprecated() + public static void getA$annotations() { + } + + public final int getB() { + return 0; + } + + @Bind(id = 100) + @java.lang.Deprecated() + public static void getB$annotations() { + } + + public final int getC() { + return 0; + } + + @Bind(id = 100) + @java.lang.Deprecated() + public static void getC$annotations() { + } + + public final int getD() { + return 0; + } + + @Bind(id = 100) + @java.lang.Deprecated() + public static void getD$annotations() { + } + + public final int getE() { + return 0; + } + + @Bind(id = 100) + @Anno(a1 = false, a2 = 1, a3 = 2, a4 = 3, a5 = 4L, a6 = '5', a7 = 6.0F, a8 = 7.0, a9 = "A") + @java.lang.Deprecated() + public static void getE$annotations() { + } + + public final int getF() { + return 0; + } + + @Bind(id = 200) + @java.lang.Deprecated() + public static void getF$annotations() { + } + + @Bind(id = 100) + public final void foo() { + } + + @Bind(id = 100) + public final void foo2() { + } + + @Bind(id = 100) + public final void foo3() { + } + + @Bind(id = 100) + public final void foo4() { + } + + @Bind(id = 100) + @Anno(a1 = false, a2 = 1, a3 = 2, a4 = 3, a5 = 4L, a6 = '5', a7 = 6.0F, a8 = 7.0, a9 = "A") + public final void foo5() { + } + + @Bind(id = 200) + public final void plainIntConstant() { + } + + @MultiValue(ids = {}) + public final void multi0() { + } + + @MultiValue(ids = {200}) + public final void multi1() { + } + + @MultiValue(ids = {200, 2}) + public final void multi2() { + } + + @MultiValue(ids = {200, 2}) + public final void multi3() { + } + + @MultiValueString(ids = {"A"}) + public final void multi4() { + } + + @MultiValueByte(ids = {1}) + public final void multi5() { + } + + @lib.OnClick(value = {200}) + public final void multiJava1() { + } + + @lib.OnClick(value = {200, 100}) + public final void multiJava2() { + } + + public final int getPropB() { + return 0; + } + + public final int getPropC() { + return 0; + } + + public final void setPropC(int p0) { + } + + public final int getPropF() { + return 0; + } +} + +//////////////////// + +package app; + +public class R { + + public R() { + super(); + } + + public static class layout { + + public layout() { + super(); + } + public static final int mainActivity = 100; + } +} + +//////////////////// + +package app; + +public class R2 { + + public R2() { + super(); + } + + public static class layout { + + public layout() { + super(); + } + public static final int mainActivity = 100; + } +} + +//////////////////// + +package lib; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(value = ElementType.METHOD) +@Retention(value = RetentionPolicy.RUNTIME) +public @interface OnClick { + + int[] value() default {}; +} + +//////////////////// + +package lib; + +public class R { + + public R() { + super(); + } + + public static class id { + + public id() { + super(); + } + public static final int textView = 100; + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/annotationsWithTargets.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/annotationsWithTargets.fir.txt new file mode 100644 index 00000000000..9ee34a08714 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/annotationsWithTargets.fir.txt @@ -0,0 +1,106 @@ +@kotlin.Metadata() +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface Anno { +} + +//////////////////// + + +@kotlin.Metadata() +public final class Bar { + @FieldAnno() + @org.jetbrains.annotations.NotNull() + private final java.lang.String a = ""; + + public Bar() { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getA() { + return null; + } + + @PropertyAnno() + @Anno() + @java.lang.Deprecated() + public static void getA$annotations() { + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class Baz { + @FieldAnno() + @kotlin.jvm.JvmField() + @org.jetbrains.annotations.NotNull() + public final java.lang.String a = ""; + + public Baz() { + super(); + } + + @Anno() + @java.lang.Deprecated() + public static void getA$annotations() { + } +} + +//////////////////// + + +@kotlin.Metadata() +@kotlin.annotation.Target(allowedTargets = {kotlin.annotation.AnnotationTarget.FIELD}) +@java.lang.annotation.Target(value = {java.lang.annotation.ElementType.FIELD}) +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface FieldAnno { +} + +//////////////////// + + +@kotlin.Metadata() +public final class Foo { + @FieldAnno() + @org.jetbrains.annotations.NotNull() + private final java.lang.String a = null; + + public Foo(@ParameterAnno() + @Anno() + @org.jetbrains.annotations.NotNull() + java.lang.String a) { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getA() { + return null; + } + + @PropertyAnno() + @java.lang.Deprecated() + public static void getA$annotations() { + } +} + +//////////////////// + + +@kotlin.Metadata() +@kotlin.annotation.Target(allowedTargets = {kotlin.annotation.AnnotationTarget.VALUE_PARAMETER}) +@java.lang.annotation.Target(value = {java.lang.annotation.ElementType.PARAMETER}) +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface ParameterAnno { +} + +//////////////////// + + +@kotlin.Metadata() +@kotlin.annotation.Target(allowedTargets = {kotlin.annotation.AnnotationTarget.PROPERTY}) +@java.lang.annotation.Target(value = {}) +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface PropertyAnno { +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/anonymousDelegate.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/anonymousDelegate.fir.txt new file mode 100644 index 00000000000..d7354dea6ab --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/anonymousDelegate.fir.txt @@ -0,0 +1,80 @@ +@kotlin.Metadata() +public final class AnonymousDelegateKt { + + public AnonymousDelegateKt() { + super(); + } + @org.jetbrains.annotations.NotNull() + private static final java.lang.Object delegate$delegate = null; + + @org.jetbrains.annotations.NotNull() + public static final java.lang.Object getDelegate() { + return null; + } + + public static final void setDelegate(@org.jetbrains.annotations.NotNull() + java.lang.Object delegate) { + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class ConcreteDelegate { + + public ConcreteDelegate() { + super(); + } + + public final int getValue(@org.jetbrains.annotations.Nullable() + java.lang.Object t, @org.jetbrains.annotations.NotNull() + kotlin.reflect.KProperty p) { + return 0; + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class Test { + @org.jetbrains.annotations.NotNull() + private final java.lang.Object broken$delegate = null; + @org.jetbrains.annotations.NotNull() + private final java.io.Serializable overridden$delegate = null; + @org.jetbrains.annotations.NotNull() + private final kotlin.Lazy lazyProp$delegate = null; + @org.jetbrains.annotations.NotNull() + private final ConcreteDelegate concreteDelegate$delegate = null; + + public Test() { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.Object getBroken() { + return null; + } + + public final void setBroken(@org.jetbrains.annotations.NotNull() + java.lang.Object broken) { + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.Object getOverridden() { + return null; + } + + public final void setOverridden(@org.jetbrains.annotations.NotNull() + java.lang.Object overridden) { + } + + private final java.lang.Runnable getLazyProp() { + return null; + } + + public final int getConcreteDelegate() { + return 0; + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/comments.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/comments.fir.txt new file mode 100644 index 00000000000..5b3440bc578 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/comments.fir.txt @@ -0,0 +1,188 @@ +@kotlin.Metadata() +@kotlin.annotation.Target(allowedTargets = {kotlin.annotation.AnnotationTarget.PROPERTY}) +@java.lang.annotation.Target(value = {}) +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface Anno { +} + +//////////////////// + + +@kotlin.Metadata() +public enum EnumError { + /*public static final*/ One /* = new EnumError() */, + /*public static final*/ Two /* = new EnumError() */; + + EnumError() { + } + + @org.jetbrains.annotations.NotNull() + public abstract java.lang.String doIt(); + + @org.jetbrains.annotations.NotNull() + public static kotlin.enums.EnumEntries getEntries() { + return null; + } +} + +//////////////////// + + +/** + * Obj. + */ +@kotlin.Metadata() +public final class Obj { + @org.jetbrains.annotations.NotNull() + public static final Obj INSTANCE = null; + + private Obj() { + super(); + } +} + +//////////////////// + + +/** + * Test. + */ +@kotlin.Metadata() +public final class Test { + + /** + * prop. + */ + @org.jetbrains.annotations.NotNull() + public final java.lang.String prop = ""; + + /** + * prop2. + */ + @org.jetbrains.annotations.NotNull() + private final java.lang.String prop2 = ""; + + public Test() { + super(); + } + + /** + * method(). + */ + public final void method() { + } + + /** + * method(int). + */ + public final void method(int a) { + } + + /** + * method(String). + */ + public final void method(@org.jetbrains.annotations.NotNull() + java.lang.String a) { + } + + /** + * prop2. + */ + @org.jetbrains.annotations.NotNull() + public final java.lang.String getProp2() { + return null; + } + + /** + * prop2. + */ + @Anno() + @java.lang.Deprecated() + public static void getProp2$annotations() { + } + + /** + * get. + */ + @org.jetbrains.annotations.NotNull() + public final java.lang.String getProp3() { + return null; + } + + /** + * set. + */ + public final void setProp3(@org.jetbrains.annotations.NotNull() + java.lang.String v) { + } +} + +//////////////////// + + +/** + * Test2 + * Multiline + * documentation. + */ +@kotlin.Metadata() +public final class Test2 { + @org.jetbrains.annotations.NotNull() + private final java.lang.String a = null; + + public Test2(@org.jetbrains.annotations.NotNull() + java.lang.String a) { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getA() { + return null; + } +} + +//////////////////// + + +/** + * constructor. + */ +@kotlin.Metadata() +public final class Test3 { + @org.jetbrains.annotations.NotNull() + private final java.lang.String a = null; + + protected Test3(@org.jetbrains.annotations.NotNull() + java.lang.String a) { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getA() { + return null; + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class Test4 { + + public Test4() { + super(); + } + + public final void method() { + } +} + +//////////////////// + + +/** + * `/ * Failure * /` + */ +@kotlin.Metadata() +public abstract interface TestComponent { +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/commentsRemoved.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/commentsRemoved.fir.txt new file mode 100644 index 00000000000..56b0312395c --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/commentsRemoved.fir.txt @@ -0,0 +1,142 @@ +@kotlin.Metadata() +@kotlin.annotation.Target(allowedTargets = {kotlin.annotation.AnnotationTarget.PROPERTY}) +@java.lang.annotation.Target(value = {}) +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface Anno { +} + +//////////////////// + + +@kotlin.Metadata() +public enum EnumError { + /*public static final*/ One /* = new EnumError() */, + /*public static final*/ Two /* = new EnumError() */; + + EnumError() { + } + + @org.jetbrains.annotations.NotNull() + public abstract java.lang.String doIt(); + + @org.jetbrains.annotations.NotNull() + public static kotlin.enums.EnumEntries getEntries() { + return null; + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class Obj { + @org.jetbrains.annotations.NotNull() + public static final Obj INSTANCE = null; + + private Obj() { + super(); + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class Test { + @org.jetbrains.annotations.NotNull() + public final java.lang.String prop = ""; + @org.jetbrains.annotations.NotNull() + private final java.lang.String prop2 = ""; + + public Test() { + super(); + } + + public final void method() { + } + + public final void method(int a) { + } + + public final void method(@org.jetbrains.annotations.NotNull() + java.lang.String a) { + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getProp2() { + return null; + } + + @Anno() + @java.lang.Deprecated() + public static void getProp2$annotations() { + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getProp3() { + return null; + } + + public final void setProp3(@org.jetbrains.annotations.NotNull() + java.lang.String v) { + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class Test2 { + @org.jetbrains.annotations.NotNull() + private final java.lang.String a = null; + + public Test2(@org.jetbrains.annotations.NotNull() + java.lang.String a) { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getA() { + return null; + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class Test3 { + @org.jetbrains.annotations.NotNull() + private final java.lang.String a = null; + + protected Test3(@org.jetbrains.annotations.NotNull() + java.lang.String a) { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getA() { + return null; + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class Test4 { + + public Test4() { + super(); + } + + public final void method() { + } +} + +//////////////////// + + +@kotlin.Metadata() +public abstract interface TestComponent { +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/dataClass.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/dataClass.fir.txt new file mode 100644 index 00000000000..671bb9fd962 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/dataClass.fir.txt @@ -0,0 +1,66 @@ +@kotlin.Metadata() +public final class User { + @org.jetbrains.annotations.NotNull() + private final java.lang.String firstName = null; + @org.jetbrains.annotations.NotNull() + private final java.lang.String secondName = null; + private final int age = 0; + + @org.jetbrains.annotations.NotNull() + public final User copy(@org.jetbrains.annotations.NotNull() + java.lang.String firstName, @org.jetbrains.annotations.NotNull() + java.lang.String secondName, int age) { + return null; + } + + public boolean equals(@org.jetbrains.annotations.Nullable() + java.lang.Object other) { + return false; + } + + public int hashCode() { + return 0; + } + + @org.jetbrains.annotations.NotNull() + public java.lang.String toString() { + return null; + } + + public User(@org.jetbrains.annotations.NotNull() + java.lang.String firstName, @org.jetbrains.annotations.NotNull() + java.lang.String secondName, int age) { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String component1() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getFirstName() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String component2() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getSecondName() { + return null; + } + + public final int component3() { + return 0; + } + + public final int getAge() { + return 0; + } + + public final void procedure() { + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/defaultImpls.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/defaultImpls.fir.txt new file mode 100644 index 00000000000..9062400158b --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/defaultImpls.fir.txt @@ -0,0 +1,41 @@ +@kotlin.Metadata() +public abstract interface Intf { + @org.jetbrains.annotations.NotNull() + public static final Intf.Companion Companion = null; + public static final int WHITE = 2; + + public default int getColor() { + return 0; + } + + @kotlin.Metadata() + public static final class Companion { + private static final int BLACK = 1; + public static final int WHITE = 2; + + private Companion() { + super(); + } + + public final int getBLACK() { + return 0; + } + } +} + +//////////////////// + + +@kotlin.Metadata() +public abstract interface IntfWithDefaultImpls { + + public default void a() { + } +} + +//////////////////// + + +@kotlin.Metadata() +public abstract interface IntfWithoutDefaultImpls { +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/defaultImplsWithTypeParameters.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/defaultImplsWithTypeParameters.fir.txt new file mode 100644 index 00000000000..e450a8fc99c --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/defaultImplsWithTypeParameters.fir.txt @@ -0,0 +1,10 @@ +@kotlin.Metadata() +public abstract interface Foo { + + public default void foo(X x, Y y, Z z) { + } + + public default int getX() { + return 0; + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/defaultPackage.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/defaultPackage.fir.txt new file mode 100644 index 00000000000..315489c060f --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/defaultPackage.fir.txt @@ -0,0 +1,64 @@ +@kotlin.Metadata() +public final class AnotherRootClass { + + public AnotherRootClass() { + super(); + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class RootClass { + + public RootClass() { + super(); + } +} + +//////////////////// + +package test; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target(value = {ElementType.TYPE, ElementType.METHOD}) +@Retention(value = RetentionPolicy.RUNTIME) +public @interface ClassRefAnnotation { + + Class[] value(); +} + +//////////////////// + +package test; + +@kotlin.Metadata() +public abstract interface PackedClass { + + @org.jetbrains.annotations.NotNull() + public abstract RootClass someMethod(); + + @org.jetbrains.annotations.NotNull() + public abstract java.lang.Number otherMethod(); + + @org.jetbrains.annotations.NotNull() + public abstract AnotherRootClass oneMoreMethod(); +} + +//////////////////// + +package test; + +@kotlin.Metadata() +@ClassRefAnnotation(value = {RootClass.class}) +public final class PackedWithAnnotation { + + public PackedWithAnnotation() { + super(); + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/defaultPackageCorrectErrorTypes.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/defaultPackageCorrectErrorTypes.fir.txt new file mode 100644 index 00000000000..315489c060f --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/defaultPackageCorrectErrorTypes.fir.txt @@ -0,0 +1,64 @@ +@kotlin.Metadata() +public final class AnotherRootClass { + + public AnotherRootClass() { + super(); + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class RootClass { + + public RootClass() { + super(); + } +} + +//////////////////// + +package test; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target(value = {ElementType.TYPE, ElementType.METHOD}) +@Retention(value = RetentionPolicy.RUNTIME) +public @interface ClassRefAnnotation { + + Class[] value(); +} + +//////////////////// + +package test; + +@kotlin.Metadata() +public abstract interface PackedClass { + + @org.jetbrains.annotations.NotNull() + public abstract RootClass someMethod(); + + @org.jetbrains.annotations.NotNull() + public abstract java.lang.Number otherMethod(); + + @org.jetbrains.annotations.NotNull() + public abstract AnotherRootClass oneMoreMethod(); +} + +//////////////////// + +package test; + +@kotlin.Metadata() +@ClassRefAnnotation(value = {RootClass.class}) +public final class PackedWithAnnotation { + + public PackedWithAnnotation() { + super(); + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/defaultParameterValueOff.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/defaultParameterValueOff.fir.txt new file mode 100644 index 00000000000..1147c288621 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/defaultParameterValueOff.fir.txt @@ -0,0 +1,148 @@ +@kotlin.Metadata() +public enum Em { + /*public static final*/ FOO /* = new Em() */, + /*public static final*/ BAR /* = new Em() */; + + Em() { + } + + @org.jetbrains.annotations.NotNull() + public static kotlin.enums.EnumEntries getEntries() { + return null; + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class Foo { + private final boolean z = false; + private final byte b = 0; + private final char c = '\u0000'; + private final char c2 = '\u0000'; + private final short sh = 0; + private final int i = 0; + private final long l = 0L; + private final float f = 0.0F; + private final double d = 0.0; + @org.jetbrains.annotations.NotNull() + private final java.lang.String s = null; + @org.jetbrains.annotations.NotNull() + private final int[] iarr = null; + @org.jetbrains.annotations.NotNull() + private final long[] larr = null; + @org.jetbrains.annotations.NotNull() + private final double[] darr = null; + @org.jetbrains.annotations.NotNull() + private final java.lang.String[] sarr = null; + @org.jetbrains.annotations.NotNull() + private final java.lang.Class cl = null; + @org.jetbrains.annotations.NotNull() + private final java.lang.Class[] clarr = null; + @org.jetbrains.annotations.NotNull() + private final Em em = null; + @org.jetbrains.annotations.NotNull() + private final Em[] emarr = null; + + public Foo() { + super(); + } + + public Foo(boolean z, byte b, char c, char c2, short sh, int i, long l, float f, double d, @org.jetbrains.annotations.NotNull() + java.lang.String s, @org.jetbrains.annotations.NotNull() + int[] iarr, @org.jetbrains.annotations.NotNull() + long[] larr, @org.jetbrains.annotations.NotNull() + double[] darr, @org.jetbrains.annotations.NotNull() + java.lang.String[] sarr, @org.jetbrains.annotations.NotNull() + java.lang.Class cl, @org.jetbrains.annotations.NotNull() + java.lang.Class[] clarr, @org.jetbrains.annotations.NotNull() + Em em, @org.jetbrains.annotations.NotNull() + Em[] emarr) { + super(); + } + + public final boolean getZ() { + return false; + } + + public final byte getB() { + return 0; + } + + public final char getC() { + return '\u0000'; + } + + public final char getC2() { + return '\u0000'; + } + + public final short getSh() { + return 0; + } + + public final int getI() { + return 0; + } + + public final long getL() { + return 0L; + } + + public final float getF() { + return 0.0F; + } + + public final double getD() { + return 0.0; + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getS() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final int[] getIarr() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final long[] getLarr() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final double[] getDarr() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String[] getSarr() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.Class getCl() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.Class[] getClarr() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final Em getEm() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final Em[] getEmarr() { + return null; + } + + public final void foo(int a) { + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/defaultParameterValueOn.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/defaultParameterValueOn.fir.txt new file mode 100644 index 00000000000..17b50cc18b2 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/defaultParameterValueOn.fir.txt @@ -0,0 +1,148 @@ +@kotlin.Metadata() +public enum Em { + /*public static final*/ FOO /* = new Em() */, + /*public static final*/ BAR /* = new Em() */; + + Em() { + } + + @org.jetbrains.annotations.NotNull() + public static kotlin.enums.EnumEntries getEntries() { + return null; + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class Foo { + private final boolean z = true; + private final byte b = (byte)0; + private final char c = 'c'; + private final char c2 = '\n'; + private final short sh = (short)10; + private final int i = 10; + private final long l = -10L; + private final float f = 1.0F; + private final double d = -1.0; + @org.jetbrains.annotations.NotNull() + private final java.lang.String s = "foo"; + @org.jetbrains.annotations.NotNull() + private final int[] iarr = {1, 2, 3}; + @org.jetbrains.annotations.NotNull() + private final long[] larr = {-1L, 0L, 1L}; + @org.jetbrains.annotations.NotNull() + private final double[] darr = {7.3}; + @org.jetbrains.annotations.NotNull() + private final java.lang.String[] sarr = {"a", "bc"}; + @org.jetbrains.annotations.NotNull() + private final java.lang.Class cl = null; + @org.jetbrains.annotations.NotNull() + private final java.lang.Class[] clarr = {}; + @org.jetbrains.annotations.NotNull() + private final Em em = Em.BAR; + @org.jetbrains.annotations.NotNull() + private final Em[] emarr = {Em.FOO, Em.BAR}; + + public Foo() { + super(); + } + + public Foo(boolean z, byte b, char c, char c2, short sh, int i, long l, float f, double d, @org.jetbrains.annotations.NotNull() + java.lang.String s, @org.jetbrains.annotations.NotNull() + int[] iarr, @org.jetbrains.annotations.NotNull() + long[] larr, @org.jetbrains.annotations.NotNull() + double[] darr, @org.jetbrains.annotations.NotNull() + java.lang.String[] sarr, @org.jetbrains.annotations.NotNull() + java.lang.Class cl, @org.jetbrains.annotations.NotNull() + java.lang.Class[] clarr, @org.jetbrains.annotations.NotNull() + Em em, @org.jetbrains.annotations.NotNull() + Em[] emarr) { + super(); + } + + public final boolean getZ() { + return false; + } + + public final byte getB() { + return 0; + } + + public final char getC() { + return '\u0000'; + } + + public final char getC2() { + return '\u0000'; + } + + public final short getSh() { + return 0; + } + + public final int getI() { + return 0; + } + + public final long getL() { + return 0L; + } + + public final float getF() { + return 0.0F; + } + + public final double getD() { + return 0.0; + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getS() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final int[] getIarr() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final long[] getLarr() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final double[] getDarr() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String[] getSarr() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.Class getCl() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.Class[] getClarr() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final Em getEm() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final Em[] getEmarr() { + return null; + } + + public final void foo(int a) { + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/delegateToList.kt b/plugins/kapt3/kapt3-compiler/testData/converter/delegateToList.kt index 5777a0c6245..5bd6ed5a7b2 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/delegateToList.kt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/delegateToList.kt @@ -1,3 +1,4 @@ +// FIR_BLOCKED: KT-60480 class MyList( private val wrappedList: List, ) : List by wrappedList diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/delegatedProperties.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/delegatedProperties.fir.txt new file mode 100644 index 00000000000..8750fc5efa4 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/delegatedProperties.fir.txt @@ -0,0 +1,66 @@ +package test; + +@kotlin.Metadata() +public final class A { + @org.jetbrains.annotations.NotNull() + private final kotlin.Lazy x$delegate = null; + @org.jetbrains.annotations.NotNull() + private final test.C z$delegate = null; + @org.jetbrains.annotations.NotNull() + private final test.C y$delegate = null; + @org.jetbrains.annotations.NotNull() + private final kotlin.Lazy> a$delegate = null; + @org.jetbrains.annotations.NotNull() + private final kotlin.Lazy> b$delegate = null; + + public A() { + super(); + } + + public final error.NonExistentClass getX() { + return null; + } + + @kotlin.Suppress(names = {"UNRESOLVED_REFERENCE"}) + @java.lang.Deprecated() + public static void getX$annotations() { + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getZ() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getY() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final test.C getA() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final test.C getB() { + return null; + } +} + +//////////////////// + +package test; + +@kotlin.Metadata() +public class C { + + public C(T v) { + super(); + } + + public final T getValue(@org.jetbrains.annotations.Nullable() + java.lang.Object p1, @org.jetbrains.annotations.Nullable() + java.lang.Object p2) { + return null; + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/delegationAndCompanionObject.kt b/plugins/kapt3/kapt3-compiler/testData/converter/delegationAndCompanionObject.kt index 009f9176a33..9f75496c8d0 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/delegationAndCompanionObject.kt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/delegationAndCompanionObject.kt @@ -1,3 +1,4 @@ +// FIR_BLOCKED: KT-60490 // CORRECT_ERROR_TYPES @Suppress("UNRESOLVED_REFERENCE") diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/deprecated.kt b/plugins/kapt3/kapt3-compiler/testData/converter/deprecated.kt index 3c8ac6f28c2..99b4fd756d5 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/deprecated.kt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/deprecated.kt @@ -1,3 +1,4 @@ +// FIR_BLOCKED: KT-60960 package deprecated @Deprecated("Deprecated annotation") diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/enumImports.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/enumImports.fir.txt new file mode 100644 index 00000000000..f505e733370 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/enumImports.fir.txt @@ -0,0 +1,16 @@ +package kapt; + +@kotlin.Metadata() +public enum Options { + /*public static final*/ A /* = new Options() */, + /*public static final*/ B /* = new Options() */, + /*public static final*/ C /* = new Options() */; + + Options() { + } + + @org.jetbrains.annotations.NotNull() + public static kotlin.enums.EnumEntries getEntries() { + return null; + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/enumInCompanion.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/enumInCompanion.fir.txt new file mode 100644 index 00000000000..18d9957390f --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/enumInCompanion.fir.txt @@ -0,0 +1,189 @@ +@kotlin.Metadata() +public final class Test { + @org.jetbrains.annotations.NotNull() + private final Test.Companion.Example foo = Test.Companion.Example.FOO; + @org.jetbrains.annotations.NotNull() + public static final Test.Companion Companion = null; + + public Test() { + super(); + } + + @kotlin.Metadata() + public static final class Companion { + + private Companion() { + super(); + } + + @kotlin.Metadata() + public static enum Example { + /*public static final*/ FOO /* = new Example() */; + + Example() { + } + + @org.jetbrains.annotations.NotNull() + public static kotlin.enums.EnumEntries getEntries() { + return null; + } + } + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class Test2 { + @org.jetbrains.annotations.NotNull() + private final Test2.Amigo.Example foo = Test2.Amigo.Example.FOO; + @org.jetbrains.annotations.NotNull() + public static final Test2.Amigo Amigo = null; + + public Test2() { + super(); + } + + @kotlin.Metadata() + public static final class Amigo { + + private Amigo() { + super(); + } + + @kotlin.Metadata() + public static enum Example { + /*public static final*/ FOO /* = new Example() */; + + Example() { + } + + @org.jetbrains.annotations.NotNull() + public static kotlin.enums.EnumEntries getEntries() { + return null; + } + } + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class Test3 { + @org.jetbrains.annotations.NotNull() + private final Test3.Amigo.Example foo = Test3.Amigo.Example.FOO; + + public Test3() { + super(); + } + + @kotlin.Metadata() + public static final class Amigo { + @org.jetbrains.annotations.NotNull() + public static final Test3.Amigo INSTANCE = null; + + private Amigo() { + super(); + } + + @kotlin.Metadata() + public static enum Example { + /*public static final*/ FOO /* = new Example() */; + + Example() { + } + + @org.jetbrains.annotations.NotNull() + public static kotlin.enums.EnumEntries getEntries() { + return null; + } + } + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class Test4 { + private final int foo = 1; + @org.jetbrains.annotations.NotNull() + public static final Test4.Companion Companion = null; + + public Test4() { + super(); + } + + @kotlin.Metadata() + public static final class Companion { + + private Companion() { + super(); + } + + @kotlin.Metadata() + public static final class Foo { + @org.jetbrains.annotations.NotNull() + public static final Test4.Companion.Foo INSTANCE = null; + public static final int constProperty = 1; + + private Foo() { + super(); + } + } + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class Test5 { + @org.jetbrains.annotations.NotNull() + private final Test5.Amigos.Companion.Goo.Example foo = Test5.Amigos.Companion.Goo.Example.FOO; + + public Test5() { + super(); + } + + @kotlin.Metadata() + public static final class Amigos { + @org.jetbrains.annotations.NotNull() + public static final Test5.Amigos.Companion Companion = null; + + public Amigos() { + super(); + } + + @kotlin.Metadata() + public static final class Companion { + + private Companion() { + super(); + } + + @kotlin.Metadata() + public static final class Goo { + + public Goo() { + super(); + } + + @kotlin.Metadata() + public static enum Example { + /*public static final*/ FOO /* = new Example() */; + + Example() { + } + + @org.jetbrains.annotations.NotNull() + public static kotlin.enums.EnumEntries getEntries() { + return null; + } + } + } + } + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/enums.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/enums.fir.txt new file mode 100644 index 00000000000..12bb5b1fb3e --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/enums.fir.txt @@ -0,0 +1,101 @@ +@kotlin.Metadata() +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface Anno1 { + + public abstract java.lang.String value(); +} + +//////////////////// + + +@kotlin.Metadata() +public enum Enum1 { + /*public static final*/ BLACK /* = new Enum1() */, + /*public static final*/ WHITE /* = new Enum1() */; + + Enum1() { + } + + @org.jetbrains.annotations.NotNull() + public static kotlin.enums.EnumEntries getEntries() { + return null; + } +} + +//////////////////// + + +@kotlin.Metadata() +public enum Enum2 { + /*public static final*/ RED /* = new Enum2() */, + /*public static final*/ WHITE /* = new Enum2() */; + @org.jetbrains.annotations.NotNull() + private final java.lang.String col = null; + private final int col2 = 0; + + Enum2(@Anno1(value = "first") + java.lang.String col, @Anno1(value = "second") + int col2) { + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getCol() { + return null; + } + + public final int getCol2() { + return 0; + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String color() { + return null; + } + + private final void privateEnumFun() { + } + + public final void publicEnumFun() { + } + + @org.jetbrains.annotations.NotNull() + public static kotlin.enums.EnumEntries getEntries() { + return null; + } +} + +//////////////////// + + +@kotlin.Metadata() +public abstract interface I { + + @kotlin.Metadata() + public static enum Nested { + /*public static final*/ WHITE /* = new Nested() */; + + Nested() { + } + + @org.jetbrains.annotations.NotNull() + public static kotlin.enums.EnumEntries getEntries() { + return null; + } + } +} + +//////////////////// + + +@kotlin.Metadata() +public enum Nested1 { + /*public static final*/ WHITE /* = new Nested1() */; + + Nested1() { + } + + @org.jetbrains.annotations.NotNull() + public static kotlin.enums.EnumEntries getEntries() { + return null; + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/enums.kt b/plugins/kapt3/kapt3-compiler/testData/converter/enums.kt index 70cccd4c6dd..21646919f38 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/enums.kt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/enums.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +EnumEntries enum class Enum1 { BLACK, WHITE } diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/errorLocationMapping.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/errorLocationMapping.fir.txt new file mode 100644 index 00000000000..2a8ff30adeb --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/errorLocationMapping.fir.txt @@ -0,0 +1,140 @@ +@kotlin.Metadata() +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface Anno { + + public abstract java.lang.Class a(); +} + +//////////////////// + + +@kotlin.Metadata() +@Anno(a = ABC.class) +public final class ErrorInAnnotation { + + public ErrorInAnnotation() { + super(); + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class ErrorInConstructorParameter { + @org.jetbrains.annotations.NotNull() + private final java.lang.String a = null; + @org.jetbrains.annotations.NotNull() + private final ABC b = null; + @org.jetbrains.annotations.NotNull() + private final java.util.List c = null; + + public ErrorInConstructorParameter(@org.jetbrains.annotations.NotNull() + java.lang.String a, @org.jetbrains.annotations.NotNull() + ABC b, @org.jetbrains.annotations.NotNull() + java.util.List c) { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getA() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final ABC getB() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final java.util.List getC() { + return null; + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class ErrorInDeclarations { + public java.lang.String p1; + public ABC p2; + public BCD p3; + + public ErrorInDeclarations() { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getP1() { + return null; + } + + public final void setP1(@org.jetbrains.annotations.NotNull() + java.lang.String p0) { + } + + @org.jetbrains.annotations.NotNull() + public final ABC getP2() { + return null; + } + + public final void setP2(@org.jetbrains.annotations.NotNull() + ABC p0) { + } + + @org.jetbrains.annotations.NotNull() + public final BCD getP3() { + return null; + } + + public final void setP3(@org.jetbrains.annotations.NotNull() + BCD p0) { + } + + public final void overloads(@org.jetbrains.annotations.NotNull() + java.lang.String a) { + } + + public final void overloads(@org.jetbrains.annotations.NotNull() + ABC a) { + } + + public final void f1(@org.jetbrains.annotations.NotNull() + java.lang.String a, @org.jetbrains.annotations.NotNull() + ABC> b) { + } + + public final void f2() { + } + + public final void f3() { + } + + @org.jetbrains.annotations.NotNull() + public final ABC f4() { + return null; + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class ErrorInSupertype implements ABC { + + public ErrorInSupertype() { + super(); + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class ErrorInSupertype2 extends ABC { + + public ErrorInSupertype2() { + super(); + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/errorSuperclass.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/errorSuperclass.fir.txt new file mode 100644 index 00000000000..058e93a1c74 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/errorSuperclass.fir.txt @@ -0,0 +1,20 @@ +package test; + +@kotlin.Metadata() +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface Anno { +} + +//////////////////// + +package test; + +@kotlin.Metadata() +@Anno() +@kotlin.Suppress(names = {"UNRESOLVED_REFERENCE"}) +public final class ClassWithParent extends Foo implements Bar, Baz, java.lang.CharSequence { + + public ClassWithParent() { + super(); + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/errorSuperclass.kt b/plugins/kapt3/kapt3-compiler/testData/converter/errorSuperclass.kt index ec2c46e01c2..67c3be63c20 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/errorSuperclass.kt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/errorSuperclass.kt @@ -1,3 +1,5 @@ +// EXPECTED_ERROR_K2: (kotlin:7:1) cannot find symbol + package test internal annotation class Anno diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/errorSuperclassCorrectErrorTypes.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/errorSuperclassCorrectErrorTypes.fir.txt new file mode 100644 index 00000000000..d337e457bd6 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/errorSuperclassCorrectErrorTypes.fir.txt @@ -0,0 +1,262 @@ +package test; + +@kotlin.Metadata() +public final class Child extends kotlin.collections.AbstractList implements test.Parent, java.util.List, kotlin.jvm.internal.markers.KMappedMarker { + + public Child() { + super(); + } +} + +//////////////////// + +package test; + +@kotlin.Metadata() +public class Cl { + + public Cl() { + super(); + } +} + +//////////////////// + +package test; + +@kotlin.Metadata() +public final class Generics1 extends Foo { + + public Generics1() { + super(); + } +} + +//////////////////// + +package test; + +@kotlin.Metadata() +public final class Generics2 implements Foo { + + public Generics2() { + super(); + } +} + +//////////////////// + +package test; + +@kotlin.Metadata() +public final class Generics3 implements Foo>, java.lang.String> { + + public Generics3() { + super(); + } +} + +//////////////////// + +package test; + +@kotlin.Metadata() +public abstract interface Intf { +} + +//////////////////// + +package test; + +@kotlin.Metadata() +public final class MappedList extends kotlin.collections.AbstractList implements java.util.List, kotlin.jvm.internal.markers.KMappedMarker { + + public MappedList() { + super(); + } + + @org.jetbrains.annotations.NotNull() + @java.lang.Override() + public java.lang.Void get(int index) { + return null; + } + + @java.lang.Override() + public int getSize() { + return 0; + } +} + +//////////////////// + +package test; + +@kotlin.Metadata() +public abstract interface Parent { +} + +//////////////////// + +package test; + +@kotlin.Metadata() +public final class TBarBazCl extends test.Cl implements Bar, Baz { + + public TBarBazCl() { + super(); + } +} + +//////////////////// + +package test; + +@kotlin.Metadata() +public final class TClBarBaz extends test.Cl implements Bar, Baz { + + public TClBarBaz() { + super(); + } +} + +//////////////////// + +package test; + +@kotlin.Metadata() +public final class TFooBar extends Foo implements Bar, test.Intf { + @org.jetbrains.annotations.NotNull() + private final X a = null; + + public TFooBar(@org.jetbrains.annotations.NotNull() + X a) { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final X getA() { + return null; + } +} + +//////////////////// + +package test; + +@kotlin.Metadata() +public final class TFooBar2 implements Foo, Bar { + @org.jetbrains.annotations.NotNull() + private final X a = null; + + public TFooBar2(@org.jetbrains.annotations.NotNull() + X a) { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final X getA() { + return null; + } +} + +//////////////////// + +package test; + +@kotlin.Metadata() +public final class TFooBarBaz extends Foo implements Bar, Baz { + + public TFooBarBaz() { + super(); + } +} + +//////////////////// + +package test; + +@kotlin.Metadata() +public final class TFooBarBaz2 extends Foo implements Baz, test.Intf { + + public TFooBarBaz2() { + super(); + } +} + +//////////////////// + +package test; + +@kotlin.Metadata() +public final class TFooBarBaz3 implements Foo, Bar, Baz { + + public TFooBarBaz3() { + super(); + } +} + +//////////////////// + +package test; + +@kotlin.Metadata() +public final class TFooBarBaz4 implements Foo, Bar, Baz { + + public TFooBarBaz4() { + super(); + } +} + +//////////////////// + +package test; + +@kotlin.Metadata() +public final class TFooBarBaz5 implements Foo, Bar, Baz { + + public TFooBarBaz5() { + super(); + } + + public TFooBarBaz5(@org.jetbrains.annotations.NotNull() + java.lang.String s) { + super(); + } +} + +//////////////////// + +package test; + +@kotlin.Metadata() +public final class TFooBarBaz6 implements Foo, Bar, Baz { + + public TFooBarBaz6(@org.jetbrains.annotations.NotNull() + java.lang.String s) { + super(); + } +} + +//////////////////// + +package test; + +@kotlin.Metadata() +public final class TxFooxBarxBaz extends x.Foo implements x.Bar, x.Baz, test.Intf { + + public TxFooxBarxBaz() { + super(); + } +} + +//////////////////// + +package test; + +@kotlin.Metadata() +public final class TxFooxBarxBaz2 extends x.Foo implements x.Bar { + + public TxFooxBarxBaz2() { + super(); + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/genericParameters.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/genericParameters.fir.txt new file mode 100644 index 00000000000..32461696bdf --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/genericParameters.fir.txt @@ -0,0 +1,28 @@ +@kotlin.Metadata() +public final class MappedList extends kotlin.collections.AbstractList implements java.util.List, kotlin.jvm.internal.markers.KMappedMarker { + @org.jetbrains.annotations.NotNull() + private final java.util.List list = null; + @org.jetbrains.annotations.NotNull() + private final kotlin.jvm.functions.Function1 function = null; + + public MappedList(@org.jetbrains.annotations.NotNull() + java.util.List list, @org.jetbrains.annotations.NotNull() + kotlin.jvm.functions.Function1 function) { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final java.util.List getList() { + return null; + } + + @java.lang.Override() + public R get(int index) { + return null; + } + + @java.lang.Override() + public int getSize() { + return 0; + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/implicitReturnTypes.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/implicitReturnTypes.fir.txt index a1f712838ea..d1b0b4c7252 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/implicitReturnTypes.fir.txt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/implicitReturnTypes.fir.txt @@ -15,8 +15,6 @@ public abstract class Prop { package test; -import java.lang.System; - @kotlin.Metadata() public final class Cl { @org.jetbrains.annotations.NotNull() @@ -41,8 +39,6 @@ public final class Cl { package test; -import java.lang.System; - @kotlin.Metadata() public final class TestKt { diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/importsForErrorTypes.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/importsForErrorTypes.fir.txt new file mode 100644 index 00000000000..2adb0b3dac4 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/importsForErrorTypes.fir.txt @@ -0,0 +1,12 @@ +@kotlin.Metadata() +public final class ImportsForErrorTypesKt { + + public ImportsForErrorTypesKt() { + super(); + } + + @org.jetbrains.annotations.Nullable() + public static final java.lang.Object test() { + return null; + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/importsKt22083.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/importsKt22083.fir.txt new file mode 100644 index 00000000000..aacbfb52992 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/importsKt22083.fir.txt @@ -0,0 +1,76 @@ +package lib; + +public class File { + + public File() { + super(); + } +} + +//////////////////// + +package lib; + +public class IOException { + + public IOException() { + super(); + } +} + +//////////////////// + +package test; + +@kotlin.Metadata() +public final class TestA { + + public TestA() { + super(); + } +} + +//////////////////// + +package test; + +@kotlin.Metadata() +public abstract interface TestB { + + @org.jetbrains.annotations.NotNull() + public abstract java.io.File a(); + + @org.jetbrains.annotations.NotNull() + public abstract lib.File b(); + + @org.jetbrains.annotations.NotNull() + public abstract java.io.IOException c(); + + @org.jetbrains.annotations.NotNull() + public abstract lib.IOException d(); +} + +//////////////////// + +package test; + +import lib.FooBar; + +@kotlin.Metadata() +public abstract interface TestC { + + @org.jetbrains.annotations.NotNull() + public abstract java.io.File a(); + + @org.jetbrains.annotations.NotNull() + public abstract lib.File b(); + + @org.jetbrains.annotations.NotNull() + public abstract java.io.IOException c(); + + @org.jetbrains.annotations.NotNull() + public abstract lib.IOException d(); + + @org.jetbrains.annotations.NotNull() + public abstract lib.FooBar e(); +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/importsKt22083.kt b/plugins/kapt3/kapt3-compiler/testData/converter/importsKt22083.kt index a8d5978577f..e143dfb801e 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/importsKt22083.kt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/importsKt22083.kt @@ -1,7 +1,6 @@ // CORRECT_ERROR_TYPES -// EXPECTED_ERROR: (kotlin:16:5) cannot find symbol - +// EXPECTED_ERROR: (kotlin:15:5) cannot find symbol // FILE: a.kt package test diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/incorrectDelegate.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/incorrectDelegate.fir.txt new file mode 100644 index 00000000000..77abea64c82 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/incorrectDelegate.fir.txt @@ -0,0 +1,50 @@ +@kotlin.Metadata() +public final class GroupedNewsListDelegateAdapter { + + public GroupedNewsListDelegateAdapter(@org.jetbrains.annotations.NotNull() + kotlin.jvm.functions.Function0 onWiFiClickListener) { + super(); + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class HomeFragment { + @org.jetbrains.annotations.NotNull() + private final kotlin.Unit categoryNewsListPresenter$delegate = null; + @org.jetbrains.annotations.NotNull() + private final kotlin.Lazy groupedNewsListAdapter$delegate = null; + + public HomeFragment() { + super(); + } + + private final error.NonExistentClass getCategoryNewsListPresenter() { + return null; + } + + @kotlin.Suppress(names = {"TOO_MANY_ARGUMENTS", "DELEGATE_SPECIAL_FUNCTION_MISSING"}) + @java.lang.Deprecated() + private static void getCategoryNewsListPresenter$annotations() { + } + + private final GroupedNewsListDelegateAdapter getGroupedNewsListAdapter() { + return null; + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class IncorrectDelegateKt { + + public IncorrectDelegateKt() { + super(); + } + + public static final void moxyPresenter() { + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/incorrectDelegate.kt b/plugins/kapt3/kapt3-compiler/testData/converter/incorrectDelegate.kt index 21948c12a71..17547d11de1 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/incorrectDelegate.kt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/incorrectDelegate.kt @@ -1,3 +1,5 @@ +// WITH_STDLIB + class HomeFragment { @Suppress("TOO_MANY_ARGUMENTS", "DELEGATE_SPECIAL_FUNCTION_MISSING") private val categoryNewsListPresenter by moxyPresenter { diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/inheritanceSimple.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/inheritanceSimple.fir.txt new file mode 100644 index 00000000000..51e901f752a --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/inheritanceSimple.fir.txt @@ -0,0 +1,53 @@ +@kotlin.Metadata() +public abstract class BaseClass { + + public BaseClass(@org.jetbrains.annotations.NotNull() + Context context, int num, boolean bool) { + super(); + } + + @org.jetbrains.annotations.NotNull() + public abstract Result doJob(); +} + +//////////////////// + + +@kotlin.Metadata() +public abstract interface Context { +} + +//////////////////// + + +@kotlin.Metadata() +public final class Inheritor extends BaseClass { + + public Inheritor(@org.jetbrains.annotations.NotNull() + Context context) { + super(null, 0, false); + } + + @org.jetbrains.annotations.NotNull() + @java.lang.Override() + public Result doJob() { + return null; + } +} + +//////////////////// + + +@kotlin.Metadata() +public enum Result { + /*public static final*/ SUCCESS /* = new Result() */, + /*public static final*/ ERROR /* = new Result() */; + + Result() { + } + + @org.jetbrains.annotations.NotNull() + public static kotlin.enums.EnumEntries getEntries() { + return null; + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/inlineClasses.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/inlineClasses.fir.txt new file mode 100644 index 00000000000..5f94beed782 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/inlineClasses.fir.txt @@ -0,0 +1,14 @@ +@kotlin.Metadata() +public final class Cl { + + public Cl() { + super(); + } + @org.jetbrains.annotations.NotNull() + private final java.lang.String a = null; + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getA() { + return null; + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/innerClassesWithTypeParameters.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/innerClassesWithTypeParameters.fir.txt new file mode 100644 index 00000000000..7e533356b16 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/innerClassesWithTypeParameters.fir.txt @@ -0,0 +1,67 @@ +@kotlin.Metadata() +public final class Test { + @org.jetbrains.annotations.NotNull() + private Test.FilterValueDelegate a; + + public Test() { + super(); + } + + @kotlin.Metadata() + private final class FilterValueDelegate { + + public FilterValueDelegate() { + super(); + } + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class Test2 { + + public Test2() { + super(); + } + + @kotlin.Metadata() + public final class FilterValueDelegate { + @org.jetbrains.annotations.NotNull() + private Test2.FilterValueDelegate.Filter2 a; + + public FilterValueDelegate() { + super(); + } + + @kotlin.Metadata() + public final class Filter2 { + + public Filter2() { + super(); + } + } + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class Test3 { + @org.jetbrains.annotations.NotNull() + private Test3.FilterValueDelegate a; + + public Test3() { + super(); + } + + @kotlin.Metadata() + private static final class FilterValueDelegate { + + public FilterValueDelegate() { + super(); + } + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/interfaceImplementation.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/interfaceImplementation.fir.txt new file mode 100644 index 00000000000..2d0a4a0f8eb --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/interfaceImplementation.fir.txt @@ -0,0 +1,30 @@ +@kotlin.Metadata() +public abstract interface Named { + + @org.jetbrains.annotations.Nullable() + public abstract java.lang.String getName(); +} + +//////////////////// + + +@kotlin.Metadata() +public final class Product2 implements Named { + @org.jetbrains.annotations.Nullable() + private java.lang.String name = null; + + @org.jetbrains.annotations.Nullable() + @java.lang.Override() + public java.lang.String getName() { + return null; + } + + public void setName(@org.jetbrains.annotations.Nullable() + java.lang.String p0) { + } + + public Product2(@org.jetbrains.annotations.NotNull() + java.lang.String otherName) { + super(); + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/invalidFieldName.kt b/plugins/kapt3/kapt3-compiler/testData/converter/invalidFieldName.kt index cf66b735754..d878b9db945 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/invalidFieldName.kt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/invalidFieldName.kt @@ -1,3 +1,4 @@ +// FIR_BLOCKED: LC don't support illegal java identifiers enum class Color { BLACK, `WHI-TE` } @@ -5,5 +6,5 @@ enum class Color { @Anno(Color.`WHI-TE`) annotation class Anno(val color: Color) -// EXPECTED_ERROR: (kotlin:5:1) an enum annotation value must be an enum constant +// EXPECTED_ERROR: (kotlin:6:1) an enum annotation value must be an enum constant // EXPECTED_ERROR: (other:-1:-1) 'WHI-TE' is an invalid Java enum value name diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/javadoc.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/javadoc.fir.txt new file mode 100644 index 00000000000..a08678a5960 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/javadoc.fir.txt @@ -0,0 +1,169 @@ +package javadoc; + +/** + * Simple + */ +@kotlin.Metadata() +public final class A { + + public A() { + super(); + } +} + +//////////////////// + +package javadoc; + +/** + * Multi + * line + * comment. + */ +@kotlin.Metadata() +public final class B { + + /** + * Nested + * member + * comment. + */ + @org.jetbrains.annotations.NotNull() + private final java.lang.String a = ""; + + /** + * Mixed + * tabs/spaces + */ + @org.jetbrains.annotations.NotNull() + private final java.lang.String b = ""; + + /** + * List: + * * first item + * * second item + */ + @org.jetbrains.annotations.NotNull() + private final java.lang.String c = ""; + + /** + * Without + * stars + */ + @org.jetbrains.annotations.NotNull() + private final java.lang.String d = ""; + + /** + * A mutable property + */ + @org.jetbrains.annotations.NotNull() + private java.lang.String e = ""; + + /** + * A property with a backing field and an explicit setter + */ + @org.jetbrains.annotations.NotNull() + private java.lang.String g; + + public B() { + super(); + } + + /** + * Nested + * member + * comment. + */ + @org.jetbrains.annotations.NotNull() + public final java.lang.String getA() { + return null; + } + + /** + * Mixed + * tabs/spaces + */ + @org.jetbrains.annotations.NotNull() + public final java.lang.String getB() { + return null; + } + + /** + * List: + * * first item + * * second item + */ + @org.jetbrains.annotations.NotNull() + public final java.lang.String getC() { + return null; + } + + /** + * Without + * stars + */ + @org.jetbrains.annotations.NotNull() + public final java.lang.String getD() { + return null; + } + + /** + * A mutable property + */ + @org.jetbrains.annotations.NotNull() + public final java.lang.String getE() { + return null; + } + + /** + * A mutable property + */ + public final void setE(@org.jetbrains.annotations.NotNull() + java.lang.String p0) { + } + + /** + * A property without a backing field + */ + @org.jetbrains.annotations.NotNull() + public final java.lang.String getF() { + return null; + } + + /** + * A property without a backing field + */ + public final void setF(@org.jetbrains.annotations.NotNull() + java.lang.String value) { + } + + /** + * A property with a backing field and an explicit setter + */ + @org.jetbrains.annotations.NotNull() + public final java.lang.String getG() { + return null; + } + + /** + * A property with a backing field and an explicit setter + */ + public final void setG(@org.jetbrains.annotations.NotNull() + java.lang.String value) { + } + + /** + * It's a getter + */ + @org.jetbrains.annotations.NotNull() + public final java.lang.String getH() { + return null; + } + + /** + * A property with documentation for an accessor + */ + public final void setH(@org.jetbrains.annotations.NotNull() + java.lang.String value) { + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/javadoc.ir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/javadoc.ir.txt index 64e2d65bec4..16d7a60e19f 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/javadoc.ir.txt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/javadoc.ir.txt @@ -53,6 +53,18 @@ public final class B { @org.jetbrains.annotations.NotNull() private final java.lang.String d = ""; + /** + * A mutable property + */ + @org.jetbrains.annotations.NotNull() + private java.lang.String e = ""; + + /** + * A property with a backing field and an explicit setter + */ + @org.jetbrains.annotations.NotNull() + private java.lang.String g; + public B() { super(); } @@ -94,4 +106,52 @@ public final class B { public final java.lang.String getD() { return null; } + + /** + * A mutable property + */ + @org.jetbrains.annotations.NotNull() + public final java.lang.String getE() { + return null; + } + + /** + * A mutable property + */ + public final void setE(@org.jetbrains.annotations.NotNull() + java.lang.String p0) { + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getF() { + return null; + } + + public final void setF(@org.jetbrains.annotations.NotNull() + java.lang.String value) { + } + + /** + * A property with a backing field and an explicit setter + */ + @org.jetbrains.annotations.NotNull() + public final java.lang.String getG() { + return null; + } + + public final void setG(@org.jetbrains.annotations.NotNull() + java.lang.String value) { + } + + /** + * It's a getter + */ + @org.jetbrains.annotations.NotNull() + public final java.lang.String getH() { + return null; + } + + public final void setH(@org.jetbrains.annotations.NotNull() + java.lang.String value) { + } } diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/javadoc.kt b/plugins/kapt3/kapt3-compiler/testData/converter/javadoc.kt index 1b751d8fbcc..d98ef33fe77 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/javadoc.kt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/javadoc.kt @@ -14,10 +14,10 @@ class B { * comment. */ val a = "" - /** - * Mixed - * tabs/spaces - */ + /** + * Mixed + * tabs/spaces + */ val b = "" /** @@ -28,8 +28,36 @@ class B { val c = "" /** - Without - stars + Without + stars */ val d = "" + + /** + * A mutable property + */ + var e = "" + + /** + * A property without a backing field + */ + var f: String + get() = "" + set(value) {} + + /** + * A property with a backing field and an explicit setter + */ + var g: String + set(value) {} + + /** + * A property with documentation for an accessor + */ + var h: String + /** + * It's a getter + */ + get() = "" + set(value) {} } diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/javadoc.txt b/plugins/kapt3/kapt3-compiler/testData/converter/javadoc.txt index bf2578dd7c5..c5f3b86b062 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/javadoc.txt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/javadoc.txt @@ -53,6 +53,18 @@ public final class B { @org.jetbrains.annotations.NotNull() private final java.lang.String d = ""; + /** + * A mutable property + */ + @org.jetbrains.annotations.NotNull() + private java.lang.String e = ""; + + /** + * A property with a backing field and an explicit setter + */ + @org.jetbrains.annotations.NotNull() + private java.lang.String g; + public B() { super(); } @@ -76,4 +88,43 @@ public final class B { public final java.lang.String getD() { return null; } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getE() { + return null; + } + + public final void setE(@org.jetbrains.annotations.NotNull() + java.lang.String p0) { + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getF() { + return null; + } + + public final void setF(@org.jetbrains.annotations.NotNull() + java.lang.String value) { + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getG() { + return null; + } + + public final void setG(@org.jetbrains.annotations.NotNull() + java.lang.String value) { + } + + /** + * It's a getter + */ + @org.jetbrains.annotations.NotNull() + public final java.lang.String getH() { + return null; + } + + public final void setH(@org.jetbrains.annotations.NotNull() + java.lang.String value) { + } } diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/jvmDefaultAll.kt b/plugins/kapt3/kapt3-compiler/testData/converter/jvmDefaultAll.kt index a26ab9b6328..b1a87a5797b 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/jvmDefaultAll.kt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/jvmDefaultAll.kt @@ -1,5 +1,6 @@ +// FIR_BLOCKED: KT-59287 // !JVM_DEFAULT_MODE: all -// EXPECTED_ERROR: (kotlin:15:5) modifier private not allowed here +// EXPECTED_ERROR: (kotlin:16:5) modifier private not allowed here interface Foo { fun foo() { diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/jvmDefaultAllCompatibility.kt b/plugins/kapt3/kapt3-compiler/testData/converter/jvmDefaultAllCompatibility.kt index b5d9feb1f1c..5533dcbc472 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/jvmDefaultAllCompatibility.kt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/jvmDefaultAllCompatibility.kt @@ -1,5 +1,6 @@ +// FIR_BLOCKED: KT-59287 // !JVM_DEFAULT_MODE: all-compatibility -// EXPECTED_ERROR: (kotlin:15:5) modifier private not allowed here +// EXPECTED_ERROR: (kotlin:16:5) modifier private not allowed here interface Foo { fun foo() { diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/jvmOverloads.kt b/plugins/kapt3/kapt3-compiler/testData/converter/jvmOverloads.kt index 3dd7e5750fd..1fdc8a2d0fa 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/jvmOverloads.kt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/jvmOverloads.kt @@ -1,4 +1,4 @@ - +// FIR_BLOCKED: support of @JvmOverloads in LC class State @JvmOverloads constructor( val someInt: Int, val someLong: Long, diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/jvmRepeatableAnnotation.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/jvmRepeatableAnnotation.fir.txt new file mode 100644 index 00000000000..2478d73be7c --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/jvmRepeatableAnnotation.fir.txt @@ -0,0 +1,19 @@ +@kotlin.Metadata() +@Condition(condition = "value1") +@Condition(condition = "value2") +public final class A { + + public A() { + super(); + } +} + +//////////////////// + + +@kotlin.Metadata() +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface Condition { + + public abstract java.lang.String condition(); +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/jvmStatic.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/jvmStatic.fir.txt new file mode 100644 index 00000000000..e3d100c042f --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/jvmStatic.fir.txt @@ -0,0 +1,66 @@ +@kotlin.Metadata() +public abstract interface FooComponent { + @org.jetbrains.annotations.NotNull() + public static final FooComponent.Companion Companion = null; + + @kotlin.jvm.JvmStatic() + @org.jetbrains.annotations.NotNull() + public static java.lang.String create(@org.jetbrains.annotations.NotNull() + java.lang.String context) { + return null; + } + + @kotlin.Metadata() + public static final class Companion { + + private Companion() { + super(); + } + + @kotlin.jvm.JvmStatic() + @org.jetbrains.annotations.NotNull() + public final java.lang.String create(@org.jetbrains.annotations.NotNull() + java.lang.String context) { + return null; + } + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class JvmStaticTest { + @org.jetbrains.annotations.NotNull() + public static final JvmStaticTest.Companion Companion = null; + private static final int one = 1; + public static final int two = 2; + public static final char c = 'C'; + public final byte three = (byte)3; + public final char d = 'D'; + + public JvmStaticTest() { + super(); + } + + public static final int getOne() { + return 0; + } + + @kotlin.Metadata() + public static final class Companion { + + private Companion() { + super(); + } + + public final int getOne() { + return 0; + } + + @kotlin.jvm.JvmStatic() + @java.lang.Deprecated() + public static void getOne$annotations() { + } + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/jvmStaticFieldInParent.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/jvmStaticFieldInParent.fir.txt new file mode 100644 index 00000000000..2769f65a7b8 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/jvmStaticFieldInParent.fir.txt @@ -0,0 +1,34 @@ +@kotlin.Metadata() +public final class Test { + @org.jetbrains.annotations.NotNull() + public static final Test.A A = null; + @org.jetbrains.annotations.NotNull() + private static final java.lang.String test = ""; + + public Test() { + super(); + } + + @org.jetbrains.annotations.NotNull() + public static final java.lang.String getTest() { + return null; + } + + @kotlin.Metadata() + public static final class A { + + private A() { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getTest() { + return null; + } + + @kotlin.jvm.JvmStatic() + @java.lang.Deprecated() + public static void getTest$annotations() { + } + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/kt14996.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/kt14996.fir.txt new file mode 100644 index 00000000000..2c3a8443bde --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/kt14996.fir.txt @@ -0,0 +1,19 @@ +@kotlin.Metadata() +public final class Kt14996Kt { + + public Kt14996Kt() { + super(); + } + + @org.jetbrains.annotations.NotNull() + public static final java.lang.CharSequence crashMe(@org.jetbrains.annotations.NotNull() + java.util.List values) { + return null; + } + + @org.jetbrains.annotations.NotNull() + public static final java.lang.String crashMe(@org.jetbrains.annotations.NotNull() + java.util.List values) { + return null; + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/kt14997.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/kt14997.fir.txt new file mode 100644 index 00000000000..cabd0fc4061 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/kt14997.fir.txt @@ -0,0 +1,62 @@ +@kotlin.Metadata() +public class CrashMe { + @org.jetbrains.annotations.NotNull() + private final java.lang.Runnable notReally = null; + + public CrashMe() { + super(); + } +} + +//////////////////// + + +@kotlin.Metadata() +@kotlin.Suppress(names = {"AMBIGUOUS_ANONYMOUS_TYPE_INFERRED"}) +public final class Kt14997Kt { + + public Kt14997Kt() { + super(); + } + + @org.jetbrains.annotations.NotNull() + public static final java.lang.Runnable a() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public static final java.io.Serializable b() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public static final CrashMe c() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public static final java.util.List d() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public static final java.lang.Runnable[] e() { + return null; + } + + public static final void e1(@org.jetbrains.annotations.NotNull() + java.lang.CharSequence[] a) { + } + + public static final void e2(@org.jetbrains.annotations.NotNull() + java.lang.Object[] a) { + } + + public static final void e3(@org.jetbrains.annotations.NotNull() + java.lang.CharSequence[] a) { + } + + public static final void e3(@org.jetbrains.annotations.NotNull() + java.lang.Object[] a) { + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/kt14998.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/kt14998.fir.txt new file mode 100644 index 00000000000..28a6a8e25cc --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/kt14998.fir.txt @@ -0,0 +1,59 @@ +@kotlin.Metadata() +public final class Outer { + + public Outer() { + super(); + } + + public final void nonAbstract(@org.jetbrains.annotations.NotNull() + java.lang.String s, int i) { + } + + @kotlin.Metadata() + private final class Inner { + @org.jetbrains.annotations.NotNull() + private final java.lang.String foo = null; + @org.jetbrains.annotations.NotNull() + private final java.lang.String bar = null; + + public Inner(@org.jetbrains.annotations.NotNull() + java.lang.String foo, @org.jetbrains.annotations.NotNull() + java.lang.String bar) { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getFoo() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getBar() { + return null; + } + } + + @kotlin.Metadata() + private static final class Nested { + @org.jetbrains.annotations.NotNull() + private final java.lang.String foo = null; + @org.jetbrains.annotations.NotNull() + private final java.lang.String bar = null; + + public Nested(@org.jetbrains.annotations.NotNull() + java.lang.String foo, @org.jetbrains.annotations.NotNull() + java.lang.String bar) { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getFoo() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getBar() { + return null; + } + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/kt17567.kt b/plugins/kapt3/kapt3-compiler/testData/converter/kt17567.kt index e7fde5e2167..09fdf0b74c4 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/kt17567.kt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/kt17567.kt @@ -4,3 +4,8 @@ internal class MutableEntry( private val internal: MutableMap, override val key: K, value: V ): MutableMap.MutableEntry + +// +// Ljava/lang/Object; +// Ljava/util/Map$Entry; +// Lkotlin/jvm/internal/markers/KMutableMap$Entry; diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/kt18682.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/kt18682.fir.txt new file mode 100644 index 00000000000..e02c7426051 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/kt18682.fir.txt @@ -0,0 +1,38 @@ +@kotlin.Metadata() +public abstract class Foo { + + public Foo() { + super(); + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class Kt18682Kt { + + public Kt18682Kt() { + super(); + } + + @org.jetbrains.annotations.NotNull() + public static final java.util.List test1() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public static final java.util.List test2() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public static final java.util.List test3() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public static final java.util.List test4() { + return null; + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/kt27126.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/kt27126.fir.txt new file mode 100644 index 00000000000..7bd6b3e3e51 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/kt27126.fir.txt @@ -0,0 +1,99 @@ +package test; + +@kotlin.Metadata() +public abstract class BundleProperty extends test.NullableBundleProperty { + + public BundleProperty(@org.jetbrains.annotations.Nullable() + java.lang.String key) { + super(null); + } + + @java.lang.Override() + public final void setValue(@org.jetbrains.annotations.NotNull() + java.lang.Object thisRef, @org.jetbrains.annotations.NotNull() + kotlin.reflect.KProperty property, @org.jetbrains.annotations.Nullable() + AA value) { + } + + @java.lang.Override() + public final AA getValue(@org.jetbrains.annotations.NotNull() + java.lang.Object thisRef, @org.jetbrains.annotations.NotNull() + kotlin.reflect.KProperty property) { + return null; + } + + @java.lang.Override() + public final void setNullableValue(@org.jetbrains.annotations.NotNull() + java.lang.Object bundle, @org.jetbrains.annotations.NotNull() + java.lang.String key, @org.jetbrains.annotations.Nullable() + AA value) { + } + + public abstract void setValue(@org.jetbrains.annotations.NotNull() + java.lang.Object bundle, @org.jetbrains.annotations.NotNull() + java.lang.String key, AA value); +} + +//////////////////// + +package test; + +@kotlin.Metadata() +@kotlin.Suppress(names = {"NOTHING_TO_INLINE"}) +public final class Kt27126Kt { + + public Kt27126Kt() { + super(); + } + + @org.jetbrains.annotations.NotNull() + public static final test.BundleProperty charSequence(@org.jetbrains.annotations.Nullable() + java.lang.String key) { + return null; + } +} + +//////////////////// + +package test; + +@kotlin.Metadata() +public abstract class NullableBundleProperty implements kotlin.properties.ReadWriteProperty { + @org.jetbrains.annotations.Nullable() + private final java.lang.String key = null; + + public NullableBundleProperty(@org.jetbrains.annotations.Nullable() + java.lang.String key) { + super(); + } + + private final java.lang.String toKey(@org.jetbrains.annotations.NotNull() + kotlin.reflect.KProperty $this$toKey) { + return null; + } + + @org.jetbrains.annotations.Nullable() + @java.lang.Override() + public EE getValue(@org.jetbrains.annotations.NotNull() + java.lang.Object thisRef, @org.jetbrains.annotations.NotNull() + kotlin.reflect.KProperty property) { + return null; + } + + @java.lang.Override() + public void setValue(@org.jetbrains.annotations.NotNull() + java.lang.Object thisRef, @org.jetbrains.annotations.NotNull() + kotlin.reflect.KProperty property, @org.jetbrains.annotations.Nullable() + EE value) { + } + + @org.jetbrains.annotations.Nullable() + public abstract EE getValue(@org.jetbrains.annotations.NotNull() + java.lang.Object bundle, @org.jetbrains.annotations.NotNull() + java.lang.String key); + + public abstract void setNullableValue(@org.jetbrains.annotations.NotNull() + java.lang.Object bundle, @org.jetbrains.annotations.NotNull() + java.lang.String key, @org.jetbrains.annotations.Nullable() + EE value); +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/kt28306.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/kt28306.fir.txt new file mode 100644 index 00000000000..4c14edb072a --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/kt28306.fir.txt @@ -0,0 +1,16 @@ +package foo; + +@kotlin.Metadata() +public abstract interface InterfaceWithDefaults { + + public default void foo() { + } +} + +//////////////////// + +package foo; + +@kotlin.Metadata() +public abstract interface SubInterface extends foo.InterfaceWithDefaults { +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/kt32596.kt b/plugins/kapt3/kapt3-compiler/testData/converter/kt32596.kt index 01f77145bc6..d1146e8fdfd 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/kt32596.kt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/kt32596.kt @@ -1,3 +1,4 @@ +// FIR_BLOCKED: KT-60482 // CORRECT_ERROR_TYPES @file:Suppress("UNRESOLVED_REFERENCE", "ANNOTATION_ARGUMENT_MUST_BE_CONST") @@ -14,6 +15,6 @@ class ErrorSomeMissingAnnotations annotation class Anno(val klass: KClass<*>) -// EXPECTED_ERROR: (kotlin:9:1) cannot find symbol -// EXPECTED_ERROR: (kotlin:12:1) cannot find symbol -// EXPECTED_ERROR: (kotlin:6:1) cannot find symbol +// EXPECTED_ERROR: (kotlin:10:1) cannot find symbol +// EXPECTED_ERROR: (kotlin:13:1) cannot find symbol +// EXPECTED_ERROR: (kotlin:7:1) cannot find symbol diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/kt43786.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/kt43786.fir.txt new file mode 100644 index 00000000000..506717f319f --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/kt43786.fir.txt @@ -0,0 +1,52 @@ +@kotlin.Metadata() +@kotlin.Suppress(names = {"UNRESOLVED_REFERENCE"}) +public final class Application { + public DataStore _preferencesDataStore; + @org.jetbrains.annotations.NotNull() + public static final Application.Companion Companion = null; + + public Application() { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final DataStore get_preferencesDataStore() { + return null; + } + + public final void set_preferencesDataStore(@org.jetbrains.annotations.NotNull() + DataStore p0) { + } + + @kotlin.jvm.JvmStatic() + @org.jetbrains.annotations.NotNull() + public static final Application get() { + return null; + } + + @kotlin.jvm.JvmStatic() + @org.jetbrains.annotations.NotNull() + public static final DataStore getPreferencesDataStore() { + return null; + } + + @kotlin.Metadata() + public static final class Companion { + + private Companion() { + super(); + } + + @kotlin.jvm.JvmStatic() + @org.jetbrains.annotations.NotNull() + public final Application get() { + return null; + } + + @kotlin.jvm.JvmStatic() + @org.jetbrains.annotations.NotNull() + public final DataStore getPreferencesDataStore() { + return null; + } + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/lazyProperty.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/lazyProperty.fir.txt new file mode 100644 index 00000000000..5344177f309 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/lazyProperty.fir.txt @@ -0,0 +1,45 @@ +@kotlin.Metadata() +public final class Foo { + @org.jetbrains.annotations.NotNull() + private final kotlin.Lazy foo$delegate = null; + @org.jetbrains.annotations.NotNull() + private final kotlin.Lazy bar$delegate = null; + @org.jetbrains.annotations.NotNull() + private final kotlin.Lazy baz$delegate = null; + @org.jetbrains.annotations.NotNull() + private final kotlin.Lazy> generic1$delegate = null; + + public Foo() { + super(); + } + + private final java.lang.Runnable getFoo() { + return null; + } + + private final java.lang.Object getBar() { + return null; + } + + private final java.lang.Object getBaz() { + return null; + } + + private final GenericIntf getGeneric1() { + return null; + } +} + +//////////////////// + + +@kotlin.Metadata() +public abstract interface GenericIntf { +} + +//////////////////// + + +@kotlin.Metadata() +public abstract interface Intf { +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/leadingDollars.kt b/plugins/kapt3/kapt3-compiler/testData/converter/leadingDollars.kt index 755636d6434..b6f3a0aa909 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/leadingDollars.kt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/leadingDollars.kt @@ -1,3 +1,4 @@ +// FIR_BLOCKED: LC don't support names with $ // CORRECT_ERROR_TYPES // FILE: $Test.java diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/leadingDollars2.kt b/plugins/kapt3/kapt3-compiler/testData/converter/leadingDollars2.kt index 57f4e3f27b9..34eab7ce95f 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/leadingDollars2.kt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/leadingDollars2.kt @@ -1,3 +1,4 @@ +// FIR_BLOCKED: LC don't support names with $ // CORRECT_ERROR_TYPES // FILE: te/st/a/JavaClass.java diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/maxErrorCount.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/maxErrorCount.fir.txt new file mode 100644 index 00000000000..727c0b2df7f --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/maxErrorCount.fir.txt @@ -0,0 +1,12 @@ +@kotlin.Metadata() +public final class Test { + + public Test() { + super(); + } + + public final void a(@org.jetbrains.annotations.NotNull() + ABC a, @org.jetbrains.annotations.NotNull() + BCD b) { + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/methodParameterNames.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/methodParameterNames.fir.txt new file mode 100644 index 00000000000..506f0fb5567 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/methodParameterNames.fir.txt @@ -0,0 +1,30 @@ +@kotlin.Metadata() +public abstract class Cls { + + public Cls() { + super(); + } + + public abstract void foo(@org.jetbrains.annotations.NotNull() + java.lang.String abc); + + @org.jetbrains.annotations.NotNull() + public final java.lang.String bar(int bcd) { + return null; + } +} + +//////////////////// + + +@kotlin.Metadata() +public abstract interface Intf { + + public abstract void foo(@org.jetbrains.annotations.NotNull() + java.lang.String abc); + + @org.jetbrains.annotations.NotNull() + public default java.lang.String bar(int bcd) { + return null; + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/modifiers.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/modifiers.fir.txt new file mode 100644 index 00000000000..b31551d031f --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/modifiers.fir.txt @@ -0,0 +1,189 @@ +package modifiers; + +@kotlin.Metadata() +public final class InternalClass { + + public InternalClass() { + super(); + } +} + +//////////////////// + +package modifiers; + +@kotlin.Metadata() +public abstract interface InternalInterface { +} + +//////////////////// + +package modifiers; + +@kotlin.Metadata() +public final class Modifiers { + @kotlin.jvm.Transient() + @org.jetbrains.annotations.NotNull() + private final transient java.lang.String transientField = ""; + @kotlin.jvm.Volatile() + @org.jetbrains.annotations.NotNull() + private volatile java.lang.String volatileField = ""; + + public Modifiers() { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getTransientField() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getVolatileField() { + return null; + } + + public final void setVolatileField(@org.jetbrains.annotations.NotNull() + java.lang.String p0) { + } + + @kotlin.jvm.Strictfp() + public final strictfp void strictFp() { + } + + @kotlin.jvm.JvmOverloads() + @org.jetbrains.annotations.NotNull() + public final java.lang.String overloads() { + return null; + } + + @kotlin.jvm.JvmOverloads() + @org.jetbrains.annotations.NotNull() + public final java.lang.String overloads(@org.jetbrains.annotations.NotNull() + java.lang.String a) { + return null; + } + + @kotlin.jvm.JvmOverloads() + @org.jetbrains.annotations.NotNull() + public final java.lang.String overloads(@org.jetbrains.annotations.NotNull() + java.lang.String a, int n) { + return null; + } +} + +//////////////////// + +package modifiers; + +@kotlin.Metadata() +final class PrivateClass { + + public PrivateClass() { + super(); + } +} + +//////////////////// + +package modifiers; + +@kotlin.Metadata() +abstract interface PrivateInterface { +} + +//////////////////// + +package modifiers; + +@kotlin.Metadata() +public final class PublicClass { + + public PublicClass() { + super(); + } +} + +//////////////////// + +package modifiers; + +@kotlin.Metadata() +public abstract class PublicClassPrivateConstructor { + + private PublicClassPrivateConstructor() { + super(); + } +} + +//////////////////// + +package modifiers; + +@kotlin.Metadata() +public class PublicClassProtectedConstructor { + + protected PublicClassProtectedConstructor() { + super(); + } + + @kotlin.Metadata() + protected static abstract interface ProtectedInterface { + } + + @kotlin.Metadata() + private static abstract interface PrivateInterface { + } +} + +//////////////////// + +package modifiers; + +@kotlin.Metadata() +public abstract interface PublicInterface { +} + +//////////////////// + +package modifiers; + +@kotlin.Metadata() +public abstract class SealedClass { + + protected SealedClass() { + super(); + } + + @kotlin.Metadata() + public static final class One extends modifiers.SealedClass { + + public One() { + super(); + } + } + + @kotlin.Metadata() + public static class Two extends modifiers.SealedClass { + + public Two() { + super(); + } + } + + @kotlin.Metadata() + public static abstract class Three extends modifiers.SealedClass.Two { + + public Three() { + super(); + } + } + + @kotlin.Metadata() + public static final class Four extends modifiers.SealedClass.Three { + + public Four() { + super(); + } + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/multifileClassDefaultPackage.ir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/multifileClassDefaultPackage.ir.txt new file mode 100644 index 00000000000..5e156921f0d --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/multifileClassDefaultPackage.ir.txt @@ -0,0 +1,40 @@ +@kotlin.Metadata() +public final class AnotherRootClass { + + public AnotherRootClass() { + super(); + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class RootClass { + + public RootClass() { + super(); + } +} + +//////////////////// + +package test; + +@kotlin.Metadata() +public final class M1 { + + public M1() { + super(); + } + + @org.jetbrains.annotations.Nullable() + public static final AnotherRootClass bar() { + return null; + } + + @org.jetbrains.annotations.Nullable() + public static final RootClass foo() { + return null; + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/multifileClassDefaultPackage.kt b/plugins/kapt3/kapt3-compiler/testData/converter/multifileClassDefaultPackage.kt new file mode 100644 index 00000000000..7f62b16081d --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/multifileClassDefaultPackage.kt @@ -0,0 +1,30 @@ +// STRICT + +// EXPECTED_ERROR: (other:-1:-1) test.M1: Can't reference type 'RootClass' from default package in Java stub. +// EXPECTED_ERROR_K2: (other:-1:-1) test.M1: Can't reference type 'AnotherRootClass' from default package in Java stub. + +// FILE: a.kt + +class RootClass + +class AnotherRootClass + +// FILE: test/b.kt + +@file:JvmMultifileClass +@file:JvmName("M1") +package test + +import RootClass + +fun foo(): RootClass? = null + +// FILE: test/c.kt + +@file:JvmMultifileClass +@file:JvmName("M1") +package test + +import AnotherRootClass + +fun bar(): AnotherRootClass? = null \ No newline at end of file diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/multifileClassDefaultPackage.txt b/plugins/kapt3/kapt3-compiler/testData/converter/multifileClassDefaultPackage.txt new file mode 100644 index 00000000000..7dda63d7fa4 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/multifileClassDefaultPackage.txt @@ -0,0 +1,40 @@ +@kotlin.Metadata() +public final class AnotherRootClass { + + public AnotherRootClass() { + super(); + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class RootClass { + + public RootClass() { + super(); + } +} + +//////////////////// + +package test; + +@kotlin.Metadata() +public final class M1 { + + public M1() { + super(); + } + + @org.jetbrains.annotations.Nullable() + public static final RootClass foo() { + return null; + } + + @org.jetbrains.annotations.Nullable() + public static final AnotherRootClass bar() { + return null; + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/nestedClasses.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/nestedClasses.fir.txt new file mode 100644 index 00000000000..bcb2298f3cb --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/nestedClasses.fir.txt @@ -0,0 +1,163 @@ +@kotlin.Metadata() +public final class A { + @org.jetbrains.annotations.Nullable() + private final A x = null; + + public A() { + super(); + } + + @org.jetbrains.annotations.Nullable() + public final A getX() { + return null; + } + + @org.jetbrains.annotations.Nullable() + public final A f1(@org.jetbrains.annotations.NotNull() + A a, @org.jetbrains.annotations.NotNull() + A.B b) { + return null; + } + + @kotlin.Metadata() + public static abstract interface B { + + @org.jetbrains.annotations.Nullable() + public abstract A.B getY(); + } + + @kotlin.Metadata() + public static final class C { + @org.jetbrains.annotations.NotNull() + public static final A.C INSTANCE = null; + + private C() { + super(); + } + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class A2 { + + public A2() { + super(); + } + + @kotlin.Metadata() + public static final class B { + + public B() { + super(); + } + + @kotlin.Metadata() + public static final class C { + + public C() { + super(); + } + + @kotlin.Metadata() + public static final class D { + + public D() { + super(); + } + + @kotlin.Metadata() + public static final class Cme { + + public Cme() { + super(); + } + } + + @kotlin.Metadata() + public static final class E { + + public E() { + super(); + } + } + } + } + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class Foo { + + public Foo() { + super(); + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class Test { + + public Test() { + super(); + } + + @kotlin.Metadata() + public static final class Nested { + + public Nested() { + super(); + } + + @kotlin.Metadata() + public static final class NestedNested { + + public NestedNested() { + super(); + } + } + } + + @kotlin.Metadata() + public final class Inner { + + public Inner() { + super(); + } + } + + @kotlin.Metadata() + public static final class NestedObject { + @org.jetbrains.annotations.NotNull() + public static final Test.NestedObject INSTANCE = null; + + private NestedObject() { + super(); + } + } + + @kotlin.Metadata() + public static abstract interface NestedInterface { + } + + @kotlin.Metadata() + public static enum NestedEnum { + /*public static final*/ BLACK /* = new NestedEnum() */, + /*public static final*/ WHITE /* = new NestedEnum() */; + + NestedEnum() { + } + + @org.jetbrains.annotations.NotNull() + public static kotlin.enums.EnumEntries getEntries() { + return null; + } + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/nestedClasses2.kt b/plugins/kapt3/kapt3-compiler/testData/converter/nestedClasses2.kt index 4a9be0b2084..fb318772199 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/nestedClasses2.kt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/nestedClasses2.kt @@ -1,3 +1,4 @@ +// FIR_BLOCKED: LC don't support names with $ // EXPECTED_ERROR: class J$B is public, should be declared in a file named J$B.java // EXPECTED_ERROR: class JavaClass is public, should be declared in a file named JavaClass.java diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/nestedClassesNonRootPackage.kt b/plugins/kapt3/kapt3-compiler/testData/converter/nestedClassesNonRootPackage.kt index a9b4eeecbdc..281fca07905 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/nestedClassesNonRootPackage.kt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/nestedClassesNonRootPackage.kt @@ -1,3 +1,4 @@ +// FIR_BLOCKED: LC don't support names with $ // EXPECTED_ERROR: class J$B is public, should be declared in a file named J$B.java // FILE: test/JavaClass.java diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/nonExistentClass.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/nonExistentClass.fir.txt new file mode 100644 index 00000000000..baa68443707 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/nonExistentClass.fir.txt @@ -0,0 +1,56 @@ +@kotlin.Metadata() +@kotlin.Suppress(names = {"UNRESOLVED_REFERENCE"}) +public final class NonExistentType { + @org.jetbrains.annotations.NotNull() + public static final NonExistentType INSTANCE = null; + @org.jetbrains.annotations.NotNull() + private static final ABCDEF a = null; + @org.jetbrains.annotations.Nullable() + private static final java.util.List b = null; + @org.jetbrains.annotations.NotNull() + private static final kotlin.jvm.functions.Function1 c = null; + @org.jetbrains.annotations.NotNull() + private static final ABCDEF, kotlin.Unit>> d = null; + + private NonExistentType() { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final ABCDEF getA() { + return null; + } + + @org.jetbrains.annotations.Nullable() + public final java.util.List getB() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final kotlin.jvm.functions.Function1 getC() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final ABCDEF, kotlin.Unit>> getD() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final Foo getFoo() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final ABCDEF a(@org.jetbrains.annotations.NotNull() + ABCDEF a, @org.jetbrains.annotations.NotNull() + java.lang.String s) { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final ABCDEF b(@org.jetbrains.annotations.NotNull() + java.lang.String s) { + return null; + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/nonExistentClassTypesConversion.kt b/plugins/kapt3/kapt3-compiler/testData/converter/nonExistentClassTypesConversion.kt index c2b941aad63..a4287801e87 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/nonExistentClassTypesConversion.kt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/nonExistentClassTypesConversion.kt @@ -1,7 +1,9 @@ +// FIR_BLOCKED: KT-59698 // CORRECT_ERROR_TYPES // NON_EXISTENT_CLASS // NO_VALIDATION // WITH_STDLIB +// FULL_JDK @file:Suppress("UNRESOLVED_REFERENCE", "ANNOTATION_ARGUMENT_MUST_BE_CONST", "NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION", "UNSUPPORTED_FEATURE") import java.util.Calendar diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/nonExistentClassWIthoutCorrection.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/nonExistentClassWIthoutCorrection.fir.txt new file mode 100644 index 00000000000..07198c11dd4 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/nonExistentClassWIthoutCorrection.fir.txt @@ -0,0 +1,118 @@ +@kotlin.Metadata() +@kotlin.Suppress(names = {"UNRESOLVED_REFERENCE"}) +public final class NonExistentClassWIthoutCorrectionKt { +} + +//////////////////// + + +@kotlin.Metadata() +public final class NonExistentType { + @org.jetbrains.annotations.NotNull() + public static final NonExistentType INSTANCE = null; + @org.jetbrains.annotations.NotNull() + private static final ABCDEF a = null; + @org.jetbrains.annotations.Nullable() + private static final java.util.List b = null; + @org.jetbrains.annotations.NotNull() + private static final kotlin.jvm.functions.Function1 c = null; + @org.jetbrains.annotations.NotNull() + private static final ABCDEF, kotlin.Unit>> d = null; + public static java.lang.String string2; + public static ABC coocoo; + public static ABC coocoo2; + public static ABC coocoo21; + public static ABC coocoo3; + public static ABC> coocoo31; + + private NonExistentType() { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final ABCDEF getA() { + return null; + } + + @org.jetbrains.annotations.Nullable() + public final java.util.List getB() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final kotlin.jvm.functions.Function1 getC() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final ABCDEF, kotlin.Unit>> getD() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getString2() { + return null; + } + + public final void setString2(@org.jetbrains.annotations.NotNull() + java.lang.String p0) { + } + + @org.jetbrains.annotations.NotNull() + public final ABC getCoocoo() { + return null; + } + + public final void setCoocoo(@org.jetbrains.annotations.NotNull() + ABC p0) { + } + + @org.jetbrains.annotations.NotNull() + public final ABC getCoocoo2() { + return null; + } + + public final void setCoocoo2(@org.jetbrains.annotations.NotNull() + ABC p0) { + } + + @org.jetbrains.annotations.NotNull() + public final ABC getCoocoo21() { + return null; + } + + public final void setCoocoo21(@org.jetbrains.annotations.NotNull() + ABC p0) { + } + + @org.jetbrains.annotations.NotNull() + public final ABC getCoocoo3() { + return null; + } + + public final void setCoocoo3(@org.jetbrains.annotations.NotNull() + ABC p0) { + } + + @org.jetbrains.annotations.NotNull() + public final ABC> getCoocoo31() { + return null; + } + + public final void setCoocoo31(@org.jetbrains.annotations.NotNull() + ABC> p0) { + } + + @org.jetbrains.annotations.NotNull() + public final ABCDEF a(@org.jetbrains.annotations.NotNull() + ABCDEF a, @org.jetbrains.annotations.NotNull() + java.lang.String s) { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final ABCDEF b(@org.jetbrains.annotations.NotNull() + java.lang.String s) { + return null; + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/primitiveTypes.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/primitiveTypes.fir.txt new file mode 100644 index 00000000000..8a81236442c --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/primitiveTypes.fir.txt @@ -0,0 +1,75 @@ +@kotlin.Metadata() +public final class PrimitiveTypes { + @org.jetbrains.annotations.NotNull() + public static final PrimitiveTypes INSTANCE = null; + public static final boolean booleanFalse = false; + public static final boolean booleanTrue = true; + public static final int int0 = 0; + public static final int intMinus1000 = -1000; + public static final int intMinValue = -2147483648; + public static final int intMaxValue = 2147483647; + public static final int intHex = -1; + public static final byte byte0 = (byte)0; + public static final byte byte50 = (byte)50; + public static final short short5 = (short)5; + public static final char charC = 'C'; + public static final char char0 = '\u0000'; + public static final char char10 = '\n'; + public static final char char13 = '\r'; + public static final long long0 = 0L; + public static final long longMaxValue = 9223372036854775807L; + public static final long longMinValue = -9223372036854775808L; + public static final long longHex = 4294967295L; + public static final float float54 = 5.4F; + private static final float floatMaxValue = 3.4028235E38F; + private static final float floatNan = 0.0F / 0.0F; + private static final float floatPositiveInfinity = 1.0F / 0.0F; + private static final float floatNegativeInfinity = -1.0F / 0.0F; + public static final double double54 = 5.4; + private static final double doubleMaxValue = 1.7976931348623157E308; + private static final double doubleNan = 0.0 / 0.0; + private static final double doublePositiveInfinity = 1.0 / 0.0; + private static final double doubleNegativeInfinity = -1.0 / 0.0; + @org.jetbrains.annotations.NotNull() + public static final java.lang.String stringHelloWorld = "Hello, world!"; + @org.jetbrains.annotations.NotNull() + public static final java.lang.String stringQuotes = "quotes \" \'\'quotes"; + @org.jetbrains.annotations.NotNull() + public static final java.lang.String stringRN = "\r\n"; + + private PrimitiveTypes() { + super(); + } + + public final float getFloatMaxValue() { + return 0.0F; + } + + public final float getFloatNan() { + return 0.0F; + } + + public final float getFloatPositiveInfinity() { + return 0.0F; + } + + public final float getFloatNegativeInfinity() { + return 0.0F; + } + + public final double getDoubleMaxValue() { + return 0.0; + } + + public final double getDoubleNan() { + return 0.0; + } + + public final double getDoublePositiveInfinity() { + return 0.0; + } + + public final double getDoubleNegativeInfinity() { + return 0.0; + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/propertyAnnotations.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/propertyAnnotations.fir.txt new file mode 100644 index 00000000000..ee706804dfa --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/propertyAnnotations.fir.txt @@ -0,0 +1,38 @@ +@kotlin.Metadata() +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface Anno { +} + +//////////////////// + + +@kotlin.Metadata() +@kotlin.annotation.Target(allowedTargets = {kotlin.annotation.AnnotationTarget.PROPERTY, kotlin.annotation.AnnotationTarget.CLASS}) +@java.lang.annotation.Target(value = {java.lang.annotation.ElementType.TYPE}) +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface Anno2 { +} + +//////////////////// + + +@kotlin.Metadata() +public final class Test { + @org.jetbrains.annotations.NotNull() + private final java.lang.String prop = "A"; + + public Test() { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getProp() { + return null; + } + + @Anno() + @Anno2() + @java.lang.Deprecated() + public static void getProp$annotations() { + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/recentlyNullable.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/recentlyNullable.fir.txt new file mode 100644 index 00000000000..95a75bd4ed8 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/recentlyNullable.fir.txt @@ -0,0 +1,44 @@ +package androidx.annotation; + +public interface Box { + + @RecentlyNullable() + public String foo(); +} + +//////////////////// + +package androidx.annotation; + +import java.lang.annotation.*; + +@Retention(value = RetentionPolicy.CLASS) +@Target(value = {ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD}) +@interface RecentlyNullable { +} + +//////////////////// + +package app; + +@kotlin.Metadata() +public final class KBox implements androidx.annotation.Box { + @org.jetbrains.annotations.NotNull() + private final androidx.annotation.Box delegate = null; + + @androidx.annotation.RecentlyNullable() + @java.lang.Override() + public java.lang.String foo() { + return null; + } + + public KBox(@org.jetbrains.annotations.NotNull() + androidx.annotation.Box delegate) { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final androidx.annotation.Box getDelegate() { + return null; + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/repeatableAnnotations.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/repeatableAnnotations.fir.txt new file mode 100644 index 00000000000..5c187203029 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/repeatableAnnotations.fir.txt @@ -0,0 +1,232 @@ +@kotlin.Metadata() +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface AnnoArray { + + public abstract int x(); + + public abstract java.lang.String[] a(); +} + +//////////////////// + + +@kotlin.Metadata() +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface AnnoBoolean { + + public abstract int x(); + + public abstract boolean bool(); +} + +//////////////////// + + +@kotlin.Metadata() +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface AnnoChar { + + public abstract int x(); + + public abstract char chr(); +} + +//////////////////// + + +@kotlin.Metadata() +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface AnnoClass { + + public abstract int x(); + + public abstract java.lang.Class c(); +} + +//////////////////// + + +@kotlin.Metadata() +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface AnnoDouble { + + public abstract int x(); + + public abstract double dbl(); +} + +//////////////////// + + +@kotlin.Metadata() +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface AnnoEnum { + + public abstract int x(); + + public abstract Color c(); +} + +//////////////////// + + +@kotlin.Metadata() +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface AnnoFloat { + + public abstract int x(); + + public abstract float flt(); +} + +//////////////////// + + +@kotlin.Metadata() +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface AnnoInt { + + public abstract int x(); + + public abstract int i(); +} + +//////////////////// + + +@kotlin.Metadata() +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface AnnoIntArray { + + public abstract int x(); + + public abstract int[] b(); +} + +//////////////////// + + +@kotlin.Metadata() +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface AnnoLong { + + public abstract int x(); + + public abstract long l(); +} + +//////////////////// + + +@kotlin.Metadata() +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface AnnoLongArray { + + public abstract int x(); + + public abstract long[] b(); +} + +//////////////////// + + +@kotlin.Metadata() +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface AnnoString { + + public abstract int x(); + + public abstract java.lang.String s(); +} + +//////////////////// + + +@kotlin.Metadata() +public enum Color { + /*public static final*/ BLACK /* = new Color() */; + + Color() { + } + + @org.jetbrains.annotations.NotNull() + public static kotlin.enums.EnumEntries getEntries() { + return null; + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class Test { + @org.jetbrains.annotations.NotNull() + private final java.lang.String value = ""; + + public Test() { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getValue() { + return null; + } + + @lib.Anno(value = "1") + @lib.Anno(value = "2", construct = {"A", "B"}) + @lib.Anno(value = "3", construct = {"C"}) + @java.lang.Deprecated() + public static void getValue$annotations() { + } +} + +//////////////////// + + +@kotlin.Metadata() +@AnnoChar(x = 100, chr = 'c') +@AnnoBoolean(x = 100, bool = false) +@AnnoInt(x = 100, i = 5) +@AnnoFloat(x = 100, flt = 1.0F) +@AnnoDouble(x = 100, dbl = 4.0) +@AnnoString(x = 100, s = "AAA") +@AnnoIntArray(x = 100, b = {1, 2, 3}) +@AnnoLongArray(x = 100, b = {1L, 3L}) +@AnnoArray(x = 100, a = {"A", "B"}) +@AnnoClass(x = 100, c = Color.class) +public final class Test2 { + + public Test2() { + super(); + } +} + +//////////////////// + +package lib; + +public @interface Anno { + + String[] construct() default {}; + + String value(); +} + +//////////////////// + +package lib; + +public class R { + + public R() { + super(); + } + + public static class id { + + public id() { + super(); + } + public static final int textView = 100; + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/secondaryConstructor.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/secondaryConstructor.fir.txt new file mode 100644 index 00000000000..828b1df4c28 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/secondaryConstructor.fir.txt @@ -0,0 +1,33 @@ +package secondary; + +@kotlin.Metadata() +public abstract interface Named { + + @org.jetbrains.annotations.Nullable() + public abstract java.lang.String getName(); +} + +//////////////////// + +package secondary; + +@kotlin.Metadata() +public final class Product2 implements secondary.Named { + @org.jetbrains.annotations.Nullable() + private java.lang.String name = null; + + @org.jetbrains.annotations.Nullable() + @java.lang.Override() + public java.lang.String getName() { + return null; + } + + public void setName(@org.jetbrains.annotations.Nullable() + java.lang.String p0) { + } + + public Product2(@org.jetbrains.annotations.NotNull() + java.lang.String otherName) { + super(); + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/starImports.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/starImports.fir.txt new file mode 100644 index 00000000000..5472ee113b5 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/starImports.fir.txt @@ -0,0 +1,43 @@ +@kotlin.Metadata() +public final class ResolvedKt { + + public ResolvedKt() { + super(); + } + @org.jetbrains.annotations.Nullable() + private static kotlin.io.encoding.Base64 base64 = null; + + @org.jetbrains.annotations.Nullable() + public static final kotlin.io.encoding.Base64 getBase64() { + return null; + } + + public static final void setBase64(@org.jetbrains.annotations.Nullable() + kotlin.io.encoding.Base64 p0) { + } +} + +//////////////////// + + +import kotlin.io.encoding.*; + +@kotlin.Metadata() +@kotlin.Suppress(names = {"UNRESOLVED_REFERENCE"}) +public final class UnresolvedKt { + + public UnresolvedKt() { + super(); + } + @org.jetbrains.annotations.NotNull() + private static Base65 base65 = null; + + @org.jetbrains.annotations.NotNull() + public static final Base65 getBase65() { + return null; + } + + public static final void setBase65(@org.jetbrains.annotations.NotNull() + Base65 p0) { + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/starImports.kt b/plugins/kapt3/kapt3-compiler/testData/converter/starImports.kt new file mode 100644 index 00000000000..793ff302044 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/starImports.kt @@ -0,0 +1,11 @@ +// CORRECT_ERROR_TYPES +// FILE: resolved.kt +import kotlin.io.encoding.* + +var base64: Base64? = null + +// FILE: unresolved.kt +@file:Suppress("UNRESOLVED_REFERENCE") +import kotlin.io.encoding.* + +var base65: Base65? = null diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/starImports.txt b/plugins/kapt3/kapt3-compiler/testData/converter/starImports.txt new file mode 100644 index 00000000000..58d867c1778 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/starImports.txt @@ -0,0 +1,45 @@ +import kotlin.io.encoding.*; + +@kotlin.Metadata() +public final class ResolvedKt { + + public ResolvedKt() { + super(); + } + @org.jetbrains.annotations.Nullable() + private static kotlin.io.encoding.Base64 base64; + + @org.jetbrains.annotations.Nullable() + public static final kotlin.io.encoding.Base64 getBase64() { + return null; + } + + public static final void setBase64(@org.jetbrains.annotations.Nullable() + kotlin.io.encoding.Base64 p0) { + } +} + +//////////////////// + + +import kotlin.io.encoding.*; + +@kotlin.Metadata() +@kotlin.Suppress(names = {"UNRESOLVED_REFERENCE"}) +public final class UnresolvedKt { + + public UnresolvedKt() { + super(); + } + @org.jetbrains.annotations.Nullable() + private static Base65 base65; + + @org.jetbrains.annotations.Nullable() + public static final Base65 getBase65() { + return null; + } + + public static final void setBase65(@org.jetbrains.annotations.Nullable() + Base65 p0) { + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/strangeIdentifiers.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/strangeIdentifiers.fir.txt new file mode 100644 index 00000000000..f15a7f6dbe4 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/strangeIdentifiers.fir.txt @@ -0,0 +1,62 @@ +@kotlin.Metadata() +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface Anno { + + public abstract StrangeEnum size(); + + public abstract java.lang.String name(); +} + +//////////////////// + + +@kotlin.Metadata() +public enum StrangeEnum { + /*public static final*/ InvalidFieldName /* = new StrangeEnum() */; + @org.jetbrains.annotations.NotNull() + private final java.lang.String size = null; + + StrangeEnum(java.lang.String size) { + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getSize() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public static kotlin.enums.EnumEntries getEntries() { + return null; + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class Test { + public final java.lang.String simpleName = null; + + public Test() { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getSimpleName() { + return null; + } + + public final void simpleFun() { + } + + @Anno(name = "Woofwoof", size = StrangeEnum.InvalidFieldName) + public final void simpleFun2(@org.jetbrains.annotations.NotNull() + java.lang.String a, @org.jetbrains.annotations.NotNull() + java.lang.String b) { + } + + public final void strangeFun4(@org.jetbrains.annotations.NotNull() + java.lang.String a, @org.jetbrains.annotations.NotNull() + java.lang.String p1_949560896) { + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/stripMetadata.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/stripMetadata.fir.txt new file mode 100644 index 00000000000..834a527c162 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/stripMetadata.fir.txt @@ -0,0 +1,49 @@ +public abstract class BaseClass { + + public BaseClass(@org.jetbrains.annotations.NotNull() + Context context, int num, boolean bool) { + super(); + } + + @org.jetbrains.annotations.NotNull() + public abstract Result doJob(); +} + +//////////////////// + + +public abstract interface Context { +} + +//////////////////// + + +public final class Inheritor extends BaseClass { + + public Inheritor(@org.jetbrains.annotations.NotNull() + Context context) { + super(null, 0, false); + } + + @org.jetbrains.annotations.NotNull() + @java.lang.Override() + public Result doJob() { + return null; + } +} + +//////////////////// + + +public enum Result { + /*public static final*/ SUCCESS /* = new Result() */, + /*public static final*/ ERROR /* = new Result() */; + + Result() { + } + + @org.jetbrains.annotations.NotNull() + public static kotlin.enums.EnumEntries getEntries() { + return null; + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/suspendErrorTypes.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/suspendErrorTypes.fir.txt new file mode 100644 index 00000000000..e4f63320339 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/suspendErrorTypes.fir.txt @@ -0,0 +1,13 @@ +@kotlin.Metadata() +public final class Foo { + + public Foo() { + super(); + } + + @org.jetbrains.annotations.Nullable() + public final java.lang.Object a(@org.jetbrains.annotations.NotNull() + kotlin.coroutines.Continuation $completion) { + return null; + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/topLevel.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/topLevel.fir.txt new file mode 100644 index 00000000000..382806c7857 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/topLevel.fir.txt @@ -0,0 +1,69 @@ +package test.another; + +@kotlin.Metadata() +@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +public abstract @interface Anno { + + public abstract java.lang.String value(); +} + +//////////////////// + +package test.another; + +@kotlin.Metadata() +public final class TopLevelKt { + + public TopLevelKt() { + super(); + } + public static final int topLevelConstProperty = 2; + private static final int topLevelProperty = 2; + + public static final void extensionFunction(@Anno(value = "rec") + @org.jetbrains.annotations.NotNull() + java.lang.String $this$extensionFunction, @Anno(value = "1") + @org.jetbrains.annotations.NotNull() + java.lang.String a, @Anno(value = "2") + @org.jetbrains.annotations.NotNull() + java.lang.String b) { + } + + @org.jetbrains.annotations.NotNull() + public static final java.lang.String getExtensionProperty(@Anno(value = "propRec") + @org.jetbrains.annotations.NotNull() + T $this$extensionProperty) { + return null; + } + + @Anno(value = "extpr") + @java.lang.Deprecated() + public static void getExtensionProperty$annotations(java.lang.Object p0) { + } + + public static final int getTopLevelProperty() { + return 0; + } + + @org.jetbrains.annotations.NotNull() + public static final java.lang.String getTopLevelProperty2() { + return null; + } + + public static final void setExtensionProperty(@Anno(value = "propRec") + @org.jetbrains.annotations.NotNull() + T $this$extensionProperty, @Anno(value = "setparam") + @org.jetbrains.annotations.NotNull() + java.lang.String setParamName) { + } + + @org.jetbrains.annotations.Nullable() + public static final java.lang.String topLevelFunction() { + return null; + } + + @org.jetbrains.annotations.Nullable() + public static final >T topLevelGenericFunction() { + return null; + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/topLevel.kt b/plugins/kapt3/kapt3-compiler/testData/converter/topLevel.kt index 4c8ad9aacfa..efbb7da4fe2 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/topLevel.kt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/topLevel.kt @@ -1,3 +1,5 @@ +// WITH_STDLIB +// FULL_JDK package test.another annotation class Anno(val value: String) diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/unsafePropertyInitializers.fir.txt b/plugins/kapt3/kapt3-compiler/testData/converter/unsafePropertyInitializers.fir.txt new file mode 100644 index 00000000000..d09cf2a22d1 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/unsafePropertyInitializers.fir.txt @@ -0,0 +1,233 @@ +@kotlin.Metadata() +public final class Boo { + @org.jetbrains.annotations.NotNull() + public static final Boo INSTANCE = null; + @org.jetbrains.annotations.NotNull() + private static final java.lang.String z = null; + + private Boo() { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getZ() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String foo() { + return null; + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class Foo { + @org.jetbrains.annotations.NotNull() + public static final Foo INSTANCE = null; + @org.jetbrains.annotations.NotNull() + public static final java.lang.String aString = "foo"; + public static final int aInt = 3; + @org.jetbrains.annotations.NotNull() + private static final java.lang.String bString = "bar"; + private static final int bInt = 5; + @org.jetbrains.annotations.NotNull() + private static java.lang.String cString = "baz"; + private static int cInt = 7; + @org.jetbrains.annotations.NotNull() + private static final java.lang.String d = null; + private static final int e = 0; + private static final int f = 8; + @org.jetbrains.annotations.NotNull() + private static final java.lang.String g = "ab"; + private static final int h = -4; + private static final int i = 2147483647; + @org.jetbrains.annotations.NotNull() + private static final java.lang.String j = null; + @org.jetbrains.annotations.NotNull() + private static final java.lang.String k = null; + + private Foo() { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getBString() { + return null; + } + + public final int getBInt() { + return 0; + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getCString() { + return null; + } + + public final void setCString(@org.jetbrains.annotations.NotNull() + java.lang.String p0) { + } + + public final int getCInt() { + return 0; + } + + public final void setCInt(int p0) { + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getD() { + return null; + } + + public final int getE() { + return 0; + } + + public final int getF() { + return 0; + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getG() { + return null; + } + + public final int getH() { + return 0; + } + + public final int getI() { + return 0; + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getJ() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String getK() { + return null; + } +} + +//////////////////// + + +@kotlin.Metadata() +public final class HavingState { + @org.jetbrains.annotations.NotNull() + private final State state = State.START; + @org.jetbrains.annotations.NotNull() + private final State[] stateArray = {State.START}; + @org.jetbrains.annotations.NotNull() + private final java.lang.String[] stringArray = {"foo"}; + @org.jetbrains.annotations.NotNull() + private final java.util.List stringList = null; + @org.jetbrains.annotations.NotNull() + private final java.lang.Integer[] intArray = {1}; + @org.jetbrains.annotations.NotNull() + private final float[] floatArray = {-1.0F}; + @org.jetbrains.annotations.NotNull() + private final java.util.List intList = null; + private final int uint = 1; + @org.jetbrains.annotations.NotNull() + private final kotlin.UInt[] uintArray = {1}; + @org.jetbrains.annotations.NotNull() + private final java.util.List uintList = null; + @org.jetbrains.annotations.NotNull() + private final kotlin.reflect.KClass clazz = null; + @org.jetbrains.annotations.NotNull() + private final java.lang.Class javaClass = null; + @org.jetbrains.annotations.NotNull() + private final kotlin.reflect.KClass anonymous = null; + + public HavingState() { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final State getState() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final State[] getStateArray() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.String[] getStringArray() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final java.util.List getStringList() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.Integer[] getIntArray() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final float[] getFloatArray() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final java.util.List getIntList() { + return null; + } + + public final int getUint() { + return 0; + } + + @org.jetbrains.annotations.NotNull() + public final kotlin.UInt[] getUintArray() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final java.util.List getUintList() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final kotlin.reflect.KClass getClazz() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.Class getJavaClass() { + return null; + } + + @org.jetbrains.annotations.NotNull() + public final kotlin.reflect.KClass getAnonymous() { + return null; + } +} + +//////////////////// + + +@kotlin.Metadata() +public enum State { + /*public static final*/ START /* = new State() */, + /*public static final*/ FINISH /* = new State() */; + + State() { + } + + @org.jetbrains.annotations.NotNull() + public static kotlin.enums.EnumEntries getEntries() { + return null; + } +} diff --git a/plugins/kapt3/kapt3-compiler/tests-gen/org/jetbrains/kotlin/kapt3/test/runners/ClassFileToSourceStubConverterTestGenerated.java b/plugins/kapt3/kapt3-compiler/tests-gen/org/jetbrains/kotlin/kapt3/test/runners/ClassFileToSourceStubConverterTestGenerated.java index 1fd6df98dbc..f78fbdf4d2c 100644 --- a/plugins/kapt3/kapt3-compiler/tests-gen/org/jetbrains/kotlin/kapt3/test/runners/ClassFileToSourceStubConverterTestGenerated.java +++ b/plugins/kapt3/kapt3-compiler/tests-gen/org/jetbrains/kotlin/kapt3/test/runners/ClassFileToSourceStubConverterTestGenerated.java @@ -535,6 +535,12 @@ public class ClassFileToSourceStubConverterTestGenerated extends AbstractClassFi runTest("plugins/kapt3/kapt3-compiler/testData/converter/multifileClass.kt"); } + @Test + @TestMetadata("multifileClassDefaultPackage.kt") + public void testMultifileClassDefaultPackage() throws Exception { + runTest("plugins/kapt3/kapt3-compiler/testData/converter/multifileClassDefaultPackage.kt"); + } + @Test @TestMetadata("nestedClasses.kt") public void testNestedClasses() throws Exception { @@ -613,6 +619,12 @@ public class ClassFileToSourceStubConverterTestGenerated extends AbstractClassFi runTest("plugins/kapt3/kapt3-compiler/testData/converter/severalPackageParts.kt"); } + @Test + @TestMetadata("starImports.kt") + public void testStarImports() throws Exception { + runTest("plugins/kapt3/kapt3-compiler/testData/converter/starImports.kt"); + } + @Test @TestMetadata("strangeIdentifiers.kt") public void testStrangeIdentifiers() throws Exception { diff --git a/plugins/kapt3/kapt3-compiler/tests-gen/org/jetbrains/kotlin/kapt3/test/runners/IrClassFileToSourceStubConverterTestGenerated.java b/plugins/kapt3/kapt3-compiler/tests-gen/org/jetbrains/kotlin/kapt3/test/runners/IrClassFileToSourceStubConverterTestGenerated.java index 90add1aafaf..9753621304c 100644 --- a/plugins/kapt3/kapt3-compiler/tests-gen/org/jetbrains/kotlin/kapt3/test/runners/IrClassFileToSourceStubConverterTestGenerated.java +++ b/plugins/kapt3/kapt3-compiler/tests-gen/org/jetbrains/kotlin/kapt3/test/runners/IrClassFileToSourceStubConverterTestGenerated.java @@ -535,6 +535,12 @@ public class IrClassFileToSourceStubConverterTestGenerated extends AbstractIrCla runTest("plugins/kapt3/kapt3-compiler/testData/converter/multifileClass.kt"); } + @Test + @TestMetadata("multifileClassDefaultPackage.kt") + public void testMultifileClassDefaultPackage() throws Exception { + runTest("plugins/kapt3/kapt3-compiler/testData/converter/multifileClassDefaultPackage.kt"); + } + @Test @TestMetadata("nestedClasses.kt") public void testNestedClasses() throws Exception { @@ -613,6 +619,12 @@ public class IrClassFileToSourceStubConverterTestGenerated extends AbstractIrCla runTest("plugins/kapt3/kapt3-compiler/testData/converter/severalPackageParts.kt"); } + @Test + @TestMetadata("starImports.kt") + public void testStarImports() throws Exception { + runTest("plugins/kapt3/kapt3-compiler/testData/converter/starImports.kt"); + } + @Test @TestMetadata("strangeIdentifiers.kt") public void testStrangeIdentifiers() throws Exception { diff --git a/plugins/kapt4/build.gradle.kts b/plugins/kapt4/build.gradle.kts index a40702f3431..a1a76579600 100644 --- a/plugins/kapt4/build.gradle.kts +++ b/plugins/kapt4/build.gradle.kts @@ -13,6 +13,17 @@ dependencies { implementation(project(":kotlin-annotation-processing-compiler")) embedded(project(":kotlin-annotation-processing-compiler")) { isTransitive = false } + implementation(project(":analysis:analysis-api-standalone")) + embedded(project(":analysis:analysis-api-standalone")) { + exclude("org.jetbrains.kotlin", "kotlin-stdlib") + exclude("org.jetbrains.kotlin", "kotlin-stdlib-common") + } + compileOnly(toolsJarApi()) + testApiJUnit5() + testApi(projectTests(":kotlin-annotation-processing-compiler")) + testRuntimeOnly(toolsJar()) + testRuntimeOnly(commonDependency("org.codehaus.woodstox:stax2-api")) + testRuntimeOnly(commonDependency("com.fasterxml:aalto-xml")) } optInToExperimentalCompilerApi() diff --git a/plugins/kapt4/src/org/jetbrains/kotlin/kapt4/Kapt4ContextForStubGeneration.kt b/plugins/kapt4/src/org/jetbrains/kotlin/kapt4/Kapt4ContextForStubGeneration.kt new file mode 100644 index 00000000000..c5d6a2278ea --- /dev/null +++ b/plugins/kapt4/src/org/jetbrains/kotlin/kapt4/Kapt4ContextForStubGeneration.kt @@ -0,0 +1,28 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.kapt4 + +import com.sun.tools.javac.tree.TreeMaker +import com.sun.tools.javac.util.Context +import org.jetbrains.kotlin.analysis.api.KtAnalysisSession +import org.jetbrains.kotlin.asJava.classes.KtLightClass +import org.jetbrains.kotlin.base.kapt3.KaptOptions +import org.jetbrains.kotlin.kapt3.base.KaptContext +import org.jetbrains.kotlin.kapt3.base.util.KaptLogger + +internal class Kapt4ContextForStubGeneration( + options: KaptOptions, + withJdk: Boolean, + logger: KaptLogger, + val analysisSession: KtAnalysisSession, + val classes: Iterable +) : KaptContext(options, withJdk, logger) { + internal val treeMaker = TreeMaker.instance(context) as Kapt4TreeMaker + + override fun preregisterTreeMaker(context: Context) { + Kapt4TreeMaker.preRegister(context) + } +} \ No newline at end of file diff --git a/plugins/kapt4/src/org/jetbrains/kotlin/kapt4/Kapt4KDocCommentKeeper.kt b/plugins/kapt4/src/org/jetbrains/kotlin/kapt4/Kapt4KDocCommentKeeper.kt new file mode 100644 index 00000000000..685c0f81f36 --- /dev/null +++ b/plugins/kapt4/src/org/jetbrains/kotlin/kapt4/Kapt4KDocCommentKeeper.kt @@ -0,0 +1,61 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.kapt4 + +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiField +import com.intellij.psi.PsiMethod +import com.sun.tools.javac.tree.JCTree +import org.jetbrains.kotlin.asJava.elements.KtLightElement +import org.jetbrains.kotlin.asJava.elements.KtLightMember +import org.jetbrains.kotlin.asJava.elements.KtLightParameter +import org.jetbrains.kotlin.kapt3.stubs.AbstractKDocCommentKeeper +import org.jetbrains.kotlin.psi.* + + +internal class Kapt4KDocCommentKeeper(context: Kapt4ContextForStubGeneration): AbstractKDocCommentKeeper(context) { + fun saveKDocComment(tree: JCTree, psiElement: PsiElement) { + val ktElement = psiElement.extractOriginalKtDeclaration() ?: return + if (psiElement is PsiField && ktElement is KtObjectDeclaration) { + // Do not write KDoc on object instance field + return + } + + val docComment = + when { + ktElement is KtProperty -> ktElement.docComment + ktElement.docComment == null && ktElement is KtPropertyAccessor -> ktElement.property.docComment + else -> ktElement.docComment + } ?: return + + if (psiElement is PsiMethod && psiElement.isConstructor && ktElement is KtClassOrObject) { + // We don't want the class comment to be duplicated on () + return + } + + saveKDocComment(tree, docComment) + } +} + +inline fun PsiElement.extractOriginalKtDeclaration(): T? { + // This when is needed to avoid recursion + val elementToExtract = when (this) { + is KtLightParameter -> when (kotlinOrigin) { + null -> method + else -> return kotlinOrigin as? T + } + else -> this + } + + return when (elementToExtract) { + is KtLightMember<*> -> { + val origin = elementToExtract.lightMemberOrigin + origin?.auxiliaryOriginalElement ?: origin?.originalElement ?: elementToExtract.kotlinOrigin + } + is KtLightElement<*, *> -> elementToExtract.kotlinOrigin + else -> null + } as? T +} diff --git a/plugins/kapt4/src/org/jetbrains/kotlin/kapt4/Kapt4LineMappingCollector.kt b/plugins/kapt4/src/org/jetbrains/kotlin/kapt4/Kapt4LineMappingCollector.kt new file mode 100644 index 00000000000..f58b1481aab --- /dev/null +++ b/plugins/kapt4/src/org/jetbrains/kotlin/kapt4/Kapt4LineMappingCollector.kt @@ -0,0 +1,50 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.kapt4 + +import com.intellij.psi.* +import com.sun.tools.javac.tree.JCTree +import org.jetbrains.kotlin.asJava.elements.KtLightElement +import org.jetbrains.kotlin.kapt3.base.stubs.KotlinPosition +import org.jetbrains.kotlin.kapt3.base.stubs.getJavacSignature +import org.jetbrains.kotlin.kapt3.stubs.KaptLineMappingCollectorBase + +internal class Kapt4LineMappingCollector: KaptLineMappingCollectorBase() { + fun registerClass(lightClass: PsiClass) { + register(lightClass, lightClass.qualifiedNameWithSlashes) + } + + fun registerMethod(lightClass: PsiClass, method: PsiMethod) { + register(method, lightClass.qualifiedNameWithSlashes + "#" + method.name + method.signature) + } + + fun registerField(lightClass: PsiClass, field: PsiField) { + register(field, lightClass.qualifiedNameWithSlashes + "#" + field.name) + } + + fun registerSignature(declaration: JCTree.JCMethodDecl, method: PsiMethod) { + signatureInfo[declaration.getJavacSignature()] = method.name + method.signature + } + + fun getPosition(lightClass: PsiClass): KotlinPosition? { + return lineInfo[lightClass.qualifiedNameWithSlashes] + } + + fun getPosition(lightClass: PsiClass, method: PsiMethod): KotlinPosition? = + lineInfo[lightClass.qualifiedNameWithSlashes + "#" + method.name + method.signature] + + fun getPosition(lightClass: PsiClass, field: PsiField): KotlinPosition? { + return lineInfo[lightClass.qualifiedNameWithSlashes + "#" + field.name] + } + + private fun register(asmNode: Any, fqName: String) { + val psiElement = (asmNode as? KtLightElement<*, *>)?.kotlinOrigin ?: return + register(fqName, psiElement) + } + + private val PsiClass.qualifiedNameWithSlashes: String + get() = qualifiedNameWithDollars?.replace(".", "/") ?: "" +} diff --git a/plugins/kapt4/src/org/jetbrains/kotlin/kapt4/Kapt4StubGenerator.kt b/plugins/kapt4/src/org/jetbrains/kotlin/kapt4/Kapt4StubGenerator.kt new file mode 100644 index 00000000000..fbc6726277f --- /dev/null +++ b/plugins/kapt4/src/org/jetbrains/kotlin/kapt4/Kapt4StubGenerator.kt @@ -0,0 +1,913 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +@file:Suppress("UnstableApiUsage") + +package org.jetbrains.kotlin.kapt4 + +import com.intellij.psi.* +import com.sun.tools.javac.code.Flags +import com.sun.tools.javac.code.TypeTag +import com.sun.tools.javac.parser.Tokens +import com.sun.tools.javac.tree.JCTree +import com.sun.tools.javac.tree.JCTree.* +import kotlinx.kapt.KaptIgnored +import org.jetbrains.kotlin.analysis.api.symbols.KtCallableSymbol +import org.jetbrains.kotlin.analysis.api.symbols.KtClassOrObjectSymbol +import org.jetbrains.kotlin.analysis.api.symbols.KtEnumEntrySymbol +import org.jetbrains.kotlin.asJava.classes.KtLightClass +import org.jetbrains.kotlin.asJava.classes.KtLightClassForFacade +import org.jetbrains.kotlin.asJava.elements.KtLightElementBase +import org.jetbrains.kotlin.base.kapt3.KaptFlag +import org.jetbrains.kotlin.builtins.StandardNames +import org.jetbrains.kotlin.idea.references.KtReference +import org.jetbrains.kotlin.kapt3.base.javac.kaptError +import org.jetbrains.kotlin.kapt3.base.javac.reportKaptError +import org.jetbrains.kotlin.kapt3.base.stubs.KaptStubLineInformation +import org.jetbrains.kotlin.kapt3.base.util.TopLevelJava9Aware +import org.jetbrains.kotlin.kapt3.stubs.MemberData +import org.jetbrains.kotlin.kapt3.stubs.MembersPositionComparator +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.SpecialNames +import org.jetbrains.kotlin.name.isOneSegmentFQN +import org.jetbrains.kotlin.psi.KtDotQualifiedExpression +import org.jetbrains.kotlin.psi.KtFile +import org.jetbrains.kotlin.psi.KtNameReferenceExpression +import org.jetbrains.kotlin.psi.KtParameter +import org.jetbrains.kotlin.resolve.calls.util.getCalleeExpressionIfAny +import org.jetbrains.kotlin.utils.addToStdlib.runIf +import org.jetbrains.kotlin.utils.addToStdlib.runUnless +import org.jetbrains.org.objectweb.asm.Opcodes +import org.jetbrains.org.objectweb.asm.Type +import java.io.File +import javax.lang.model.element.ElementKind +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract +import kotlin.math.sign + +context(Kapt4ContextForStubGeneration) +internal class Kapt4StubGenerator { + private companion object { + private const val VISIBILITY_MODIFIERS = (Opcodes.ACC_PUBLIC or Opcodes.ACC_PRIVATE or Opcodes.ACC_PROTECTED).toLong() + private const val MODALITY_MODIFIERS = (Opcodes.ACC_FINAL or Opcodes.ACC_ABSTRACT).toLong() + + private const val CLASS_MODIFIERS = VISIBILITY_MODIFIERS or MODALITY_MODIFIERS or + (Opcodes.ACC_DEPRECATED or Opcodes.ACC_INTERFACE or Opcodes.ACC_ANNOTATION or Opcodes.ACC_ENUM or Opcodes.ACC_STATIC).toLong() + + private const val METHOD_MODIFIERS = VISIBILITY_MODIFIERS or MODALITY_MODIFIERS or + (Opcodes.ACC_DEPRECATED or Opcodes.ACC_SYNCHRONIZED or Opcodes.ACC_NATIVE or Opcodes.ACC_STATIC or Opcodes.ACC_STRICT).toLong() + + private const val FIELD_MODIFIERS = VISIBILITY_MODIFIERS or MODALITY_MODIFIERS or + (Opcodes.ACC_VOLATILE or Opcodes.ACC_TRANSIENT or Opcodes.ACC_ENUM or Opcodes.ACC_STATIC).toLong() + + private const val PARAMETER_MODIFIERS = FIELD_MODIFIERS or Flags.PARAMETER or Flags.VARARGS or Opcodes.ACC_FINAL.toLong() + + private val BLACKLISTED_ANNOTATIONS = listOf( + "java.lang.Synthetic", + "synthetic.kotlin.jvm.GeneratedByJvmOverloads" // kapt3-related annotation for marking JvmOverloads-generated methods + ) + + private val KOTLIN_METADATA_ANNOTATION = Metadata::class.java.name + + private val JAVA_KEYWORD_FILTER_REGEX = "[a-z]+".toRegex() + + @Suppress("UselessCallOnNotNull") // nullable toString(), KT-27724 + private val JAVA_KEYWORDS = Tokens.TokenKind.values() + .filter { JAVA_KEYWORD_FILTER_REGEX.matches(it.toString().orEmpty()) } + .mapTo(hashSetOf(), Any::toString) + } + + private val strictMode = options[KaptFlag.STRICT] + private val stripMetadata = options[KaptFlag.STRIP_METADATA] + private val keepKdocComments = options[KaptFlag.KEEP_KDOC_COMMENTS_IN_STUBS] + private val dumpDefaultParameterValues = options[KaptFlag.DUMP_DEFAULT_PARAMETER_VALUES] + + private val kdocCommentKeeper = runIf(keepKdocComments) { Kapt4KDocCommentKeeper(this@Kapt4ContextForStubGeneration) } + + internal fun generateStubs(): Map { + return classes.associateWith { convertTopLevelClass(it) } + } + + private fun convertTopLevelClass(lightClass: KtLightClass): KaptStub? { + val ktFiles = when(lightClass) { + is KtLightClassForFacade -> lightClass.files + else -> listOfNotNull(lightClass.kotlinOrigin?.containingKtFile) + } + val lineMappings = Kapt4LineMappingCollector() + val packageName = (lightClass.parent as? PsiJavaFile)?.packageName ?: return null + val packageClause = runUnless(packageName.isBlank()) { treeMaker.FqName(packageName) } + + val unresolvedQualifiersRecorder = UnresolvedQualifiersRecorder(ktFiles) + val classDeclaration = with(unresolvedQualifiersRecorder) { + convertClass(lightClass, lineMappings, packageName) ?: return null + } + + val classes = JavacList.of(classDeclaration) + + // imports should be collected after class conversion to + val imports = ktFiles.fold(JavacList.nil()) { acc, file -> + acc.appendList(convertImports(file, unresolvedQualifiersRecorder)) + } + + val topLevel = treeMaker.TopLevelJava9Aware(packageClause, imports + classes) + if (kdocCommentKeeper != null) { + topLevel.docComments = kdocCommentKeeper.getDocTable(topLevel) + } + + return KaptStub(topLevel, lineMappings.serialize()) + } + + context(UnresolvedQualifiersRecorder) + private fun convertClass( + lightClass: PsiClass, + lineMappings: Kapt4LineMappingCollector, + packageFqName: String + ): JCClassDecl? { + if (!checkIfValidTypeName(lightClass, lightClass.defaultType)) return null + + val parentClass = lightClass.parent as? PsiClass + + val flags = if ((parentClass?.isInterface == true || parentClass?.isAnnotationType == true) && !lightClass.isPublic) + (lightClass.accessFlags and Flags.PRIVATE.toLong().inv()) else lightClass.accessFlags + + val metadata = calculateMetadata(lightClass) + + val isEnum = lightClass.isEnum + val modifiers = convertModifiers( + lightClass, + flags, + if (isEnum) ElementKind.ENUM else ElementKind.CLASS, + packageFqName, + lightClass.annotations.toList(), + metadata, + ) + + val simpleName = lightClass.name!! + if (!isValidIdentifier(simpleName)) return null + + val classSignature = parseClassSignature(lightClass) + + val enumValues: JavacList = mapJList(lightClass.fields) { field -> + if (field !is PsiEnumConstant) return@mapJList null + val constructorArguments = lightClass.constructors.firstOrNull()?.parameters?.mapNotNull { it.type as? PsiType }.orEmpty() + val args = mapJList(constructorArguments) { convertLiteralExpression(getDefaultValue(it)) } + + convertField( + field, lightClass, lineMappings, packageFqName, treeMaker.NewClass( + /* enclosing = */ null, + /* typeArgs = */ JavacList.nil(), + /* lightClass = */ treeMaker.Ident(treeMaker.name(field.name)), + /* args = */ args, + /* def = */ null + ) + ) + } + + val fieldsPositions = mutableMapOf() + val fields = mapJList(lightClass.fields) { field -> + runUnless(field is PsiEnumConstant) { convertField(field, lightClass, lineMappings, packageFqName)?.also { + fieldsPositions[it] = MemberData(field.name, field.signature, lineMappings.getPosition(lightClass, field)) + } + } + } + + val methodsPositions = mutableMapOf() + val methods = mapJList(lightClass.methods) { method -> + if (isEnum && method.isSyntheticStaticEnumMethod()) { + return@mapJList null + } + + convertMethod(method, lightClass, lineMappings, packageFqName)?.also { + methodsPositions[it] = MemberData(method.name, method.signature, lineMappings.getPosition(lightClass, method)) + } + } + + val nestedClasses = mapJList(lightClass.innerClasses) { innerClass -> + convertClass(innerClass, lineMappings, packageFqName) + } + + lineMappings.registerClass(lightClass) + + val classPosition = lineMappings.getPosition(lightClass) + val sortedFields = JavacList.from(fields.sortedWith(MembersPositionComparator(classPosition, fieldsPositions))) + val sortedMethods = JavacList.from(methods.sortedWith(MembersPositionComparator(classPosition, methodsPositions))) + + return treeMaker.ClassDef( + modifiers, + treeMaker.name(simpleName), + classSignature.typeParameters, + classSignature.superClass.takeUnless { classSignature.superClassIsObject || lightClass.isEnum }, + classSignature.interfaces, + JavacList.from(enumValues + sortedFields + sortedMethods + nestedClasses) + ).keepKdocCommentsIfNecessary(lightClass) + } + + private fun PsiMethod.isSyntheticStaticEnumMethod(): Boolean { + if (!this.isStatic) return false + return when (name) { + StandardNames.ENUM_VALUES.asString() -> parameters.isEmpty() + StandardNames.ENUM_VALUE_OF.asString() -> (parameters.singleOrNull()?.type as? PsiClassType)?.qualifiedName == "java.lang.String" + else -> false + } + } + + private fun convertImports(file: KtFile, unresolvedQualifiers: UnresolvedQualifiersRecorder): JavacList { + if (unresolvedQualifiers.isEmpty()) return JavacList.nil() + + val imports = mutableListOf() + val importedShortNames = mutableSetOf() + + // We prefer ordinary imports over aliased ones. + val sortedImportDirectives = file.importDirectives.partition { it.aliasName == null }.run { first + second } + + loop@ for (importDirective in sortedImportDirectives) { + val acceptableByName = when { + importDirective.isAllUnder -> unresolvedQualifiers.simpleNames.isNotEmpty() + else -> { + val fqName = importDirective.importedFqName ?: continue + fqName.asString() in unresolvedQualifiers.qualifiedNames || fqName.shortName().identifier in unresolvedQualifiers.simpleNames + } + } + + if (!acceptableByName) continue + + val importedSymbols = with(analysisSession) { + val importedReference = importDirective.importedReference + ?.getCalleeExpressionIfAny() + ?.references + ?.firstOrNull() as? KtReference + importedReference?.resolveToSymbols().orEmpty() + } + + val isAllUnderClassifierImport = importDirective.isAllUnder && importedSymbols.any { it is KtClassOrObjectSymbol } + val isCallableImport = !importDirective.isAllUnder && importedSymbols.any { it is KtCallableSymbol } + val isEnumEntryImport = !importDirective.isAllUnder && importedSymbols.any { it is KtEnumEntrySymbol } + + if (isAllUnderClassifierImport || isCallableImport || isEnumEntryImport) continue + + + // Qualified name should be valid Java fq-name + val importedFqName = importDirective.importedFqName?.takeIf { it.pathSegments().size > 1 } ?: continue + if (!isValidQualifiedName(importedFqName)) continue + val importedExpr = treeMaker.FqName(importedFqName.asString()) + imports += if (importDirective.isAllUnder) { + treeMaker.Import(treeMaker.Select(importedExpr, treeMaker.nameTable.names.asterisk), false) + } else { + if (!importedShortNames.add(importedFqName.shortName().asString())) { + continue + } + + treeMaker.Import(importedExpr, false) + } + } + + return JavacList.from(imports) + } + + private fun convertMetadataAnnotation(metadata: Metadata): JCAnnotation { + val argumentsWithNames = mapOf( + "k" to metadata.kind, + "mv" to metadata.metadataVersion.toList(), + "bv" to metadata.bytecodeVersion.toList(), + "d1" to metadata.data1.toList(), + "d2" to metadata.data2.toList(), + "xs" to metadata.extraString, + "pn" to metadata.packageName, + "xi" to metadata.extraInt, + ) + val arguments = argumentsWithNames.map { (name, value) -> + val jValue = convertLiteralExpression(value) + treeMaker.Assign(treeMaker.SimpleName(name), jValue) + } + return treeMaker.Annotation(treeMaker.FqName(Metadata::class.java.canonicalName), JavacList.from(arguments)) + } + + context(UnresolvedQualifiersRecorder) + private fun convertAnnotation( + containingClass: PsiClass, + annotation: PsiAnnotation, + packageFqName: String + ): JCAnnotation? { + val rawQualifiedName = annotation.qualifiedName ?: return null + val fqName = treeMaker.getQualifiedName(rawQualifiedName) + + if (BLACKLISTED_ANNOTATIONS.any { fqName.startsWith(it) }) return null + if (stripMetadata && fqName == KOTLIN_METADATA_ANNOTATION) return null + + + val annotationFqName = annotation.resolveAnnotationType()?.defaultType.convertAndRecordErrors { + val useSimpleName = '.' in fqName && fqName.substringBeforeLast('.', "") == packageFqName + + when { + useSimpleName -> treeMaker.FqName(fqName.substring(packageFqName.length + 1)) + else -> treeMaker.FqName(fqName) + } + } + + val values = mapJList<_, JCExpression>(annotation.parameterList.attributes) { + val name = it.name?.takeIf { name -> isValidIdentifier(name) } ?: return@mapJList null + val value = it.value + val expr = if (value == null) { + ((it as? KtLightElementBase)?.kotlinOrigin as? KtDotQualifiedExpression)?.let { convertDotQualifiedExpression(it) } + ?: return@mapJList null + } else { + convertPsiAnnotationMemberValue(containingClass, value, packageFqName) + } + treeMaker.Assign(treeMaker.SimpleName(name), expr) + } + + return treeMaker.Annotation(annotationFqName, values) + } + + private fun convertDotQualifiedExpression(dotQualifiedExpression: KtDotQualifiedExpression): JCExpression? { + val qualifier = dotQualifiedExpression.lastChild as? KtNameReferenceExpression ?: return null + val name = qualifier.text.takeIf { isValidIdentifier(it) } ?: "InvalidFieldName" + val lhs = when(val left = dotQualifiedExpression.firstChild) { + is KtNameReferenceExpression -> treeMaker.SimpleName(left.getReferencedName()) + is KtDotQualifiedExpression -> convertDotQualifiedExpression(left) ?: return null + else -> return null + } + return treeMaker.Select(lhs, treeMaker.name(name)) + } + + context(UnresolvedQualifiersRecorder) + private fun convertPsiAnnotationMemberValue( + containingClass: PsiClass, + value: PsiAnnotationMemberValue, + packageFqName: String, + ): JCExpression? { + return when (value) { + is PsiArrayInitializerMemberValue -> { + val arguments = mapJList(value.initializers) { + convertPsiAnnotationMemberValue(containingClass, it, packageFqName) + } + treeMaker.NewArray(null, null, arguments) + } + + is PsiLiteral -> convertLiteralExpression(value.value) + is PsiClassObjectAccessExpression -> { + val type = value.operand.type + checkIfValidTypeName(containingClass, type) + treeMaker.Select(treeMaker.SimpleName(type.qualifiedName), treeMaker.name("class")) + } + is PsiAnnotation -> convertAnnotation(containingClass, value, packageFqName) + else -> treeMaker.SimpleName(value.text) + } + } + + context(UnresolvedQualifiersRecorder) + private fun convertModifiers( + containingClass: PsiClass, + access: Long, + kind: ElementKind, + packageFqName: String, + allAnnotations: List, + metadata: Metadata?, + excludeNullabilityAnnotations: Boolean = false, + ): JCModifiers { + var seenDeprecated = false + fun convertAndAdd(list: JavacList, annotation: PsiAnnotation): JavacList { + seenDeprecated = seenDeprecated or annotation.hasQualifiedName("java.lang.Deprecated") + if (excludeNullabilityAnnotations && + (annotation.hasQualifiedName("org.jetbrains.annotations.NotNull") || annotation.hasQualifiedName("org.jetbrains.annotations.Nullable")) + ) return list + val annotationTree = convertAnnotation(containingClass, annotation, packageFqName) ?: return list + return list.prepend(annotationTree) + } + + var annotations = allAnnotations.reversed().fold(JavacList.nil(), ::convertAndAdd) + + if (!seenDeprecated && isDeprecated(access)) { + val type = treeMaker.RawType(Type.getType(java.lang.Deprecated::class.java)) + annotations = annotations.append(treeMaker.Annotation(type, JavacList.nil())) + } + if (metadata != null) { + annotations = annotations.prepend(convertMetadataAnnotation(metadata)) + } + + val flags = when (kind) { + ElementKind.ENUM -> access and CLASS_MODIFIERS and Opcodes.ACC_ABSTRACT.inv().toLong() + ElementKind.CLASS -> access and CLASS_MODIFIERS + ElementKind.METHOD -> access and METHOD_MODIFIERS + ElementKind.FIELD -> access and FIELD_MODIFIERS + ElementKind.PARAMETER -> access and PARAMETER_MODIFIERS + else -> throw IllegalArgumentException("Invalid element kind: $kind") + } + return treeMaker.Modifiers(flags, annotations) + } + + class KaptStub(val file: JCCompilationUnit, private val kaptMetadata: ByteArray) { + fun writeMetadataIfNeeded(forSource: File): File { + val metadataFile = File( + forSource.parentFile, + forSource.nameWithoutExtension + KaptStubLineInformation.KAPT_METADATA_EXTENSION + ) + + metadataFile.writeBytes(kaptMetadata) + return metadataFile + } + } + + context(UnresolvedQualifiersRecorder) + private fun convertField( + field: PsiField, + containingClass: PsiClass, + lineMappings: Kapt4LineMappingCollector, + packageFqName: String, + explicitInitializer: JCExpression? = null + ): JCVariableDecl? { + val fieldAnnotations = field.annotations.asList() + + if (isIgnored(fieldAnnotations)) return null + + val access = field.accessFlags + val modifiers = convertModifiers( + containingClass, + access, ElementKind.FIELD, packageFqName, + fieldAnnotations, + metadata = null + ) + + val name = field.name + if (!isValidIdentifier(name)) return null + + val type = field.type + + if (!checkIfValidTypeName(containingClass, type)) return null + + // Enum type must be an identifier (Javac requirement) + val typeExpression = if (isEnum(access)) { + treeMaker.SimpleName(treeMaker.getQualifiedName(type as PsiClassType).substringAfterLast('.')) + } else { + type.convertAndRecordErrors() + } + + lineMappings.registerField(containingClass, field) + val skip = field.navigationElement is KtParameter && !dumpDefaultParameterValues + val initializer = + explicitInitializer ?: convertPropertyInitializer(if (skip) null else field.initializer, field.type, field.isFinal) + return treeMaker.VarDef(modifiers, treeMaker.name(name), typeExpression, initializer).keepKdocCommentsIfNecessary(field) + } + + private fun convertPropertyInitializer(propertyInitializer: PsiExpression?, type: PsiType, usedDefault: Boolean): JCExpression? { + if (propertyInitializer != null || usedDefault) { + return when (propertyInitializer) { + is PsiLiteralExpression -> { + val rawValue = propertyInitializer.value + val rawNumberValue = rawValue as? Number + val actualValue = when (type) { + PsiType.BYTE -> rawNumberValue?.toByte() + PsiType.SHORT -> rawNumberValue?.toShort() + PsiType.INT -> rawNumberValue?.toInt() + PsiType.LONG -> rawNumberValue?.toLong() + PsiType.FLOAT -> rawNumberValue?.toFloat() + PsiType.DOUBLE -> rawNumberValue?.toDouble() + else -> null + } ?: rawValue + convertValueOfPrimitiveTypeOrString(actualValue) + } + is PsiPrefixExpression -> { + assert(propertyInitializer.operationSign.tokenType == JavaTokenType.MINUS) + val operand = convertPropertyInitializer(propertyInitializer.operand, type, usedDefault) + if (operand.toString().startsWith("-")) operand // overflow + else treeMaker.Unary(Tag.NEG, operand) + } + is PsiBinaryExpression -> { + assert(propertyInitializer.operationSign.tokenType == JavaTokenType.DIV) + treeMaker.Binary( + Tag.DIV, + convertPropertyInitializer(propertyInitializer.lOperand, type, false), + convertPropertyInitializer(propertyInitializer.rOperand, type, false) + ) + } + is PsiReferenceExpression -> + when (val resolved = propertyInitializer.resolve()) { + is PsiEnumConstant -> + treeMaker.FqName(resolved.containingClass!!.qualifiedName + "." + resolved.name) + else -> null + } + is PsiArrayInitializerExpression -> + treeMaker.NewArray( + null, JavacList.nil(), + mapJList(propertyInitializer.initializers) { convertPropertyInitializer(it, type.deepComponentType, false) } + ) + else -> convertLiteralExpression(getDefaultValue(type)) + } + } + + return null + } + + private fun convertLiteralExpression(value: Any?): JCExpression { + fun convertDeeper(value: Any?) = convertLiteralExpression(value) + + convertValueOfPrimitiveTypeOrString(value)?.let { return it } + + return when (value) { + null -> treeMaker.Literal(TypeTag.BOT, null) + + is ByteArray -> treeMaker.NewArray(null, JavacList.nil(), mapJList(value.asIterable(), ::convertDeeper)) + is BooleanArray -> treeMaker.NewArray(null, JavacList.nil(), mapJList(value.asIterable(), ::convertDeeper)) + is CharArray -> treeMaker.NewArray(null, JavacList.nil(), mapJList(value.asIterable(), ::convertDeeper)) + is ShortArray -> treeMaker.NewArray(null, JavacList.nil(), mapJList(value.asIterable(), ::convertDeeper)) + is IntArray -> treeMaker.NewArray(null, JavacList.nil(), mapJList(value.asIterable(), ::convertDeeper)) + is LongArray -> treeMaker.NewArray(null, JavacList.nil(), mapJList(value.asIterable(), ::convertDeeper)) + is FloatArray -> treeMaker.NewArray(null, JavacList.nil(), mapJList(value.asIterable(), ::convertDeeper)) + is DoubleArray -> treeMaker.NewArray(null, JavacList.nil(), mapJList(value.asIterable(), ::convertDeeper)) + is Array<*> -> { // Two-element String array for enumerations ([desc, fieldName]) + assert(value.size == 2) + val enumType = Type.getType(value[0] as String) + val valueName = (value[1] as String).takeIf { isValidIdentifier(it) } ?: run { + compiler.log.report(kaptError("'${value[1]}' is an invalid Java enum value name")) + "InvalidFieldName" + } + + treeMaker.Select(treeMaker.RawType(enumType), treeMaker.name(valueName)) + } + + is List<*> -> treeMaker.NewArray(null, JavacList.nil(), mapJList(value, ::convertDeeper)) + + else -> throw IllegalArgumentException("Illegal literal expression value: $value (${value::class.java.canonicalName})") + } + } + + + private fun getDefaultValue(type: PsiType): Any? = when (type) { + PsiType.BYTE -> 0 + PsiType.BOOLEAN -> false + PsiType.CHAR -> '\u0000' + PsiType.SHORT -> 0 + PsiType.INT -> 0 + PsiType.LONG -> 0L + PsiType.FLOAT -> 0.0F + PsiType.DOUBLE -> 0.0 + else -> null + } + + private fun convertValueOfPrimitiveTypeOrString(value: Any?): JCExpression? { + fun specialFpValueNumerator(value: Double): Double = if (value.isNaN()) 0.0 else 1.0 * value.sign + val convertedValue = when (value) { + is Char -> treeMaker.Literal(TypeTag.CHAR, value.code) + is Byte -> treeMaker.TypeCast(treeMaker.TypeIdent(TypeTag.BYTE), treeMaker.Literal(TypeTag.INT, value.toInt())) + is Short -> treeMaker.TypeCast(treeMaker.TypeIdent(TypeTag.SHORT), treeMaker.Literal(TypeTag.INT, value.toInt())) + is Boolean, is Int, is Long, is String -> treeMaker.Literal(value) + is Float -> when { + value.isFinite() -> treeMaker.Literal(value) + else -> treeMaker.Binary( + Tag.DIV, + treeMaker.Literal(specialFpValueNumerator(value.toDouble()).toFloat()), + treeMaker.Literal(0.0F) + ) + } + + is Double -> when { + value.isFinite() -> treeMaker.Literal(value) + else -> treeMaker.Binary(Tag.DIV, treeMaker.Literal(specialFpValueNumerator(value)), treeMaker.Literal(0.0)) + } + null -> treeMaker.Literal(TypeTag.BOT, null) + else -> null + } + + return convertedValue + } + + context(UnresolvedQualifiersRecorder) + private fun convertMethod( + method: PsiMethod, + containingClass: PsiClass, + lineMappings: Kapt4LineMappingCollector, + packageFqName: String, + ): JCMethodDecl? { + if (isIgnored(method.annotations.asList())) return null + + val isConstructor = method.isConstructor + + val name = method.name + if (!isConstructor && !isValidIdentifier(name)) return null + val returnType = method.returnType ?: PsiType.VOID + val modifiers = convertModifiers( + containingClass, + if (containingClass.isEnum && isConstructor) + (method.accessFlags and VISIBILITY_MODIFIERS.inv()) + else + method.accessFlags, + ElementKind.METHOD, + packageFqName, + method.annotations.toList(), + metadata = null, + excludeNullabilityAnnotations = returnType == PsiType.VOID + ) + + if (method.hasModifierProperty(PsiModifier.DEFAULT)) { + modifiers.flags = modifiers.flags or Flags.DEFAULT + } + + val parametersInfo = method.getParametersInfo() + + if (!checkIfValidTypeName(containingClass, returnType) + || parametersInfo.any { !checkIfValidTypeName(containingClass, it.type) } + ) { + return null + } + + @Suppress("NAME_SHADOWING") + val jParameters = mapJListIndexed(parametersInfo) { index, info -> + val lastParameter = index == parametersInfo.lastIndex + val isArrayType = info.type is PsiArrayType + + val varargs = if (lastParameter && isArrayType && method.isVarArgs) Flags.VARARGS else 0L + val modifiers = convertModifiers( + containingClass, + Flags.PARAMETER or varargs, // Kapt never marked method parameters as "final" + ElementKind.PARAMETER, + packageFqName, + info.annotations, + metadata = null + ) + + val defaultName = info.name + val name = when { + isValidIdentifier(defaultName) -> defaultName + defaultName == SpecialNames.IMPLICIT_SET_PARAMETER.asString() -> "p0" + else -> "p${index}_${info.name.hashCode().ushr(1)}" + } + val type = info.type.convertAndRecordErrors() + treeMaker.VarDef(modifiers, treeMaker.name(name), type, null) + } + val jTypeParameters = mapJList(method.typeParameters) { convertTypeParameter(it) } + val jExceptionTypes = mapJList(method.throwsTypes) { treeMaker.TypeWithArguments(it as PsiType) } + val jReturnType = runUnless(isConstructor) { + returnType.convertAndRecordErrors() + } + + val defaultValue = (method as? PsiAnnotationMethod)?.defaultValue?.let { + convertPsiAnnotationMemberValue(containingClass, it, packageFqName) + } + + val body = if (defaultValue != null) { + null + } else if (method.isAbstract or (modifiers.flags and Flags.ABSTRACT.toLong() != 0L)) { + null + } else if (isConstructor && containingClass.isEnum) { + treeMaker.Block(0, JavacList.nil()) + } else if (isConstructor) { + val superConstructor = containingClass.superClass?.constructors?.firstOrNull { !it.isPrivate } + val superClassConstructorCall = if (superConstructor != null) { + val args = mapJList(superConstructor.parameterList.parameters) { param -> + convertLiteralExpression(getDefaultValue(param.type)) + } + val call = treeMaker.Apply(JavacList.nil(), treeMaker.SimpleName("super"), args) + JavacList.of(treeMaker.Exec(call)) + } else { + JavacList.nil() + } + treeMaker.Block(0, superClassConstructorCall) + } else if (returnType == PsiType.VOID) { + treeMaker.Block(0, JavacList.nil()) + } else { + val returnStatement = treeMaker.Return(convertLiteralExpression(getDefaultValue(returnType))) + treeMaker.Block(0, JavacList.of(returnStatement)) + } + + lineMappings.registerMethod(containingClass, method) + + return treeMaker.MethodDef( + modifiers, treeMaker.name(name), jReturnType, jTypeParameters, + jParameters, jExceptionTypes, + body, defaultValue + ).keepSignature(lineMappings, method).keepKdocCommentsIfNecessary(method) + } + + private fun JCMethodDecl.keepSignature(lineMappings: Kapt4LineMappingCollector, method: PsiMethod): JCMethodDecl { + lineMappings.registerSignature(this, method) + return this + } + + private fun T.keepKdocCommentsIfNecessary(element: PsiElement): T { + kdocCommentKeeper?.saveKDocComment(this, element) + return this + } + + private fun isIgnored(annotations: List?): Boolean { + val kaptIgnoredAnnotationFqName = KaptIgnored::class.java.canonicalName + return annotations?.any { it.hasQualifiedName(kaptIgnoredAnnotationFqName) } ?: false + } + + context(UnresolvedQualifiersRecorder) + private fun checkIfValidTypeName( + containingClass: PsiClass, + type: PsiType + ): Boolean { + when (type) { + is PsiArrayType -> return checkIfValidTypeName(containingClass, type.componentType) + is PsiPrimitiveType -> return true + } + + + val internalName = type.qualifiedName + // Ignore type names with Java keywords in it + if (internalName.split('/', '.').any { it in JAVA_KEYWORDS }) { + if (strictMode) { + reportKaptError( + "Can't generate a stub for '${internalName}'.", + "Type name '${type.qualifiedName}' contains a Java keyword." + ) + } + + return false + } + + val clazz = type.resolvedClass ?: return true + + if (doesInnerClassNameConflictWithOuter(clazz)) { + if (strictMode) { + reportKaptError( + "Can't generate a stub for '${clazz.qualifiedNameWithDollars}'.", + "Its name '${clazz.name}' is the same as one of the outer class names.", + "Java forbids it. Please change one of the class names." + ) + } + + return false + } + + reportIfIllegalTypeUsage(containingClass, type) + + return true + } + + private fun findContainingClassNode(clazz: PsiClass): PsiClass? { + return clazz.parent as? PsiClass + } + + // Java forbids outer and inner class names to be the same. Check if the names are different + private tailrec fun doesInnerClassNameConflictWithOuter( + clazz: PsiClass, + outerClass: PsiClass? = findContainingClassNode(clazz) + ): Boolean { + if (outerClass == null) return false + if (treeMaker.getSimpleName(clazz) == treeMaker.getSimpleName(outerClass)) return true + // Try to find the containing class for outerClassNode (to check the whole tree recursively) + val containingClassForOuterClass = findContainingClassNode(outerClass) ?: return false + return doesInnerClassNameConflictWithOuter(clazz, containingClassForOuterClass) + } + + context(UnresolvedQualifiersRecorder) + private fun reportIfIllegalTypeUsage( + containingClass: PsiClass, + type: PsiType + ) { + val typeName = type.simpleNameOrNull ?: return + if (typeName !in reportedTypes && typeName in importsFromRoot) { + reportedTypes += typeName + val msg = "${containingClass.qualifiedName}: Can't reference type '${typeName}' from default package in Java stub." + if (strictMode) reportKaptError(msg) + else logger.warn(msg) + } + } + + context(UnresolvedQualifiersRecorder) + @OptIn(ExperimentalContracts::class) + private inline fun PsiType?.convertAndRecordErrors( + ifNonError: () -> JCExpression = { treeMaker.TypeWithArguments(this!!) } + ): JCExpression { + contract { + callsInPlace(ifNonError, InvocationKind.EXACTLY_ONCE) + } + this?.recordErrorTypes() + return ifNonError() + } + + context(UnresolvedQualifiersRecorder) + private fun PsiType.recordErrorTypes() { + if (this is PsiEllipsisType) { + this.componentType.recordErrorTypes() + return + } + if (qualifiedNameOrNull == null) { + recordUnresolvedQualifier(qualifiedName) + } + when (this) { + is PsiClassType -> typeArguments().forEach { (it as? PsiType)?.recordErrorTypes() } + is PsiArrayType -> componentType.recordErrorTypes() + } + } + + private fun isValidQualifiedName(name: FqName) = name.pathSegments().all { isValidIdentifier(it.asString()) } + + private fun isValidIdentifier(name: String): Boolean { + if (name in JAVA_KEYWORDS) return false + + return !(name.isEmpty() + || !Character.isJavaIdentifierStart(name[0]) + || name.drop(1).any { !Character.isJavaIdentifierPart(it) }) + } + + private class ClassGenericSignature( + val typeParameters: JavacList, + val superClass: JCExpression, + val interfaces: JavacList, + val superClassIsObject: Boolean + ) + + context(UnresolvedQualifiersRecorder) + private fun parseClassSignature(psiClass: PsiClass): ClassGenericSignature { + val superClasses = mutableListOf() + val superInterfaces = mutableListOf() + + val superPsiClasses = psiClass.extendsListTypes.toList() + val superPsiInterfaces = psiClass.implementsListTypes.toList() + + fun addSuperType(superType: PsiClassType, destination: MutableList) { + if (psiClass.isAnnotationType && superType.qualifiedName == "java.lang.annotation.Annotation") return + destination += superType.convertAndRecordErrors() + } + + var superClassIsObject = false + + superPsiClasses.forEach { + addSuperType(it, superClasses) + superClassIsObject = superClassIsObject || it.qualifiedNameOrNull == "java.lang.Object" + } + for (superInterface in superPsiInterfaces) { + if (superInterface.qualifiedName.startsWith("kotlin.collections.")) continue + addSuperType(superInterface, superInterfaces) + } + + val jcTypeParameters = mapJList(psiClass.typeParameters) { convertTypeParameter(it) } + val jcSuperClass = superClasses.firstOrNull().takeUnless { psiClass.isInterface } ?: createJavaLangObjectType().also { + superClassIsObject = true + } + val jcInterfaces = JavacList.from(if (psiClass.isInterface) superClasses else superInterfaces) + return ClassGenericSignature(jcTypeParameters, jcSuperClass, jcInterfaces, superClassIsObject) + } + + private fun createJavaLangObjectType(): JCExpression { + return treeMaker.FqName("java.lang.Object") + } + + context(UnresolvedQualifiersRecorder) + private fun convertTypeParameter(typeParameter: PsiTypeParameter): JCTypeParameter { + val classBounds = mutableListOf() + val interfaceBounds = mutableListOf() + + val bounds = typeParameter.bounds + for (bound in bounds) { + val boundType = bound as? PsiType ?: continue + val jBound = boundType.convertAndRecordErrors() + if (boundType.resolvedClass?.isInterface == false) { + classBounds += jBound + } else { + interfaceBounds += jBound + } + } + if (classBounds.isEmpty() && interfaceBounds.isEmpty()) { + classBounds += createJavaLangObjectType() + } + return treeMaker.TypeParameter(treeMaker.name(typeParameter.name!!), JavacList.from(classBounds + interfaceBounds)) + } + + private class UnresolvedQualifiersRecorder(ktFiles: Iterable) { + val importsFromRoot: Set by lazy { + val importsFromRoot = + ktFiles + .flatMap { it.importDirectives } + .filter { !it.isAllUnder } + .mapNotNull { im -> im.importPath?.fqName?.takeIf { it.isOneSegmentFQN() } } + importsFromRoot.mapTo(mutableSetOf()) { it.asString() } + } + + private val _qualifiedNames = mutableSetOf() + private val _simpleNames = mutableSetOf() + val reportedTypes = mutableSetOf() + + val qualifiedNames: Set + get() = _qualifiedNames + val simpleNames: Set + get() = _simpleNames + + fun isEmpty(): Boolean { + return simpleNames.isEmpty() + } + + fun recordUnresolvedQualifier(qualifier: String) { + val separated = qualifier.split(".") + if (separated.size > 1) { + _qualifiedNames += qualifier + _simpleNames += separated.first() + } else { + _simpleNames += qualifier + } + } + } + + @Suppress("UNUSED_PARAMETER") + private fun calculateMetadata(lightClass: PsiClass): Metadata? { + if (stripMetadata) return null + + return Metadata() // TODO: calculate me + } +} \ No newline at end of file diff --git a/plugins/kapt4/src/org/jetbrains/kotlin/kapt4/Kapt4TreeMaker.kt b/plugins/kapt4/src/org/jetbrains/kotlin/kapt4/Kapt4TreeMaker.kt new file mode 100644 index 00000000000..a24115d7751 --- /dev/null +++ b/plugins/kapt4/src/org/jetbrains/kotlin/kapt4/Kapt4TreeMaker.kt @@ -0,0 +1,141 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.kapt4 + +import com.intellij.psi.* +import com.sun.tools.javac.code.BoundKind +import com.sun.tools.javac.code.TypeTag +import com.sun.tools.javac.tree.JCTree +import com.sun.tools.javac.tree.TreeMaker +import com.sun.tools.javac.util.Context +import com.sun.tools.javac.util.Name +import com.sun.tools.javac.util.Names +import org.jetbrains.kotlin.builtins.StandardNames +import org.jetbrains.kotlin.codegen.AsmUtil +import org.jetbrains.org.objectweb.asm.Type +import org.jetbrains.org.objectweb.asm.Type.* + +internal class Kapt4TreeMaker( + context: Context +) : TreeMaker(context) { + val nameTable: Name.Table = Names.instance(context).table + + @Suppress("FunctionName") + fun RawType(type: Type): JCTree.JCExpression { + convertBuiltinType(type)?.let { return it } + if (type.sort == ARRAY) { + return TypeArray(RawType(AsmUtil.correctElementType(type))) + } + return FqName(type.internalName) + } + + @Suppress("FunctionName") + private fun RawType(type: PsiType): JCTree.JCExpression { + return when (type) { + is PsiArrayType -> TypeArray(RawType(type.componentType)) + is PsiWildcardType -> Wildcard(TypeBoundKind(BoundKind.UNBOUND), null) + else -> FqName(type.qualifiedName) + } + } + + @Suppress("FunctionName") + fun TypeWithArguments(type: PsiType): JCTree.JCExpression { + return when (type) { + is PsiArrayType -> TypeArray(TypeWithArguments(type.componentType)) + is PsiClassType -> { + val correctedType = if (isErroneous(type)) type.rawType() else type + SimpleName(correctedType.canonicalText.replace('$', '.')) + } // TODO: Produce a proper expression, see KT-60821 + is PsiWildcardType -> { + val argumentType = type.bound?.let { TypeWithArguments(it) } + when { + type.isExtends -> Wildcard(TypeBoundKind(BoundKind.EXTENDS), argumentType) + type.isSuper -> Wildcard(TypeBoundKind(BoundKind.SUPER), argumentType) + else -> Wildcard(TypeBoundKind(BoundKind.UNBOUND), argumentType) + } + } + + else -> RawType(type) + } + } + + private fun isErroneous(type: PsiType): Boolean { + if (type.canonicalText == StandardNames.NON_EXISTENT_CLASS.asString()) return true + if (type is PsiClassType) return type.parameters.any { isErroneous(it) } + return false + } + + @Suppress("FunctionName") + fun FqName(internalOrFqName: String): JCTree.JCExpression { + val path = getQualifiedName(internalOrFqName).convertSpecialFqName().split('.') + assert(path.isNotEmpty()) + return FqName(path) + } + + @Suppress("FunctionName") + private fun FqName(path: List): JCTree.JCExpression { + if (path.size == 1) return SimpleName(path.single()) + + var expr = Select(SimpleName(path[0]), name(path[1])) + for (index in 2..path.lastIndex) { + expr = Select(expr, name(path[index])) + } + return expr + } + + fun getQualifiedName(type: PsiClassType): String { + val klass = type.resolve() ?: return getQualifiedName(type.qualifiedName) + return getQualifiedName(klass) + } + + private fun getQualifiedName(type: PsiClass): String = getQualifiedName(type.qualifiedName!!) + + fun getSimpleName(clazz: PsiClass): String = clazz.name!! + + fun getQualifiedName(internalName: String): String { + val nameWithDots = internalName.replace('/', '.') + // This is a top-level class + if ('$' !in nameWithDots) return nameWithDots + + return nameWithDots.replace('$', '.') + } + + private fun String.convertSpecialFqName(): String { + // Hard-coded in ImplementationBodyCodegen, KOTLIN_MARKER_INTERFACES + if (this == "kotlin.jvm.internal.markers.KMutableMap\$Entry") { + return replace('$', '.') + } + + return this + } + + private fun convertBuiltinType(type: Type): JCTree.JCExpression? { + val typeTag = when (type) { + BYTE_TYPE -> TypeTag.BYTE + BOOLEAN_TYPE -> TypeTag.BOOLEAN + CHAR_TYPE -> TypeTag.CHAR + SHORT_TYPE -> TypeTag.SHORT + INT_TYPE -> TypeTag.INT + LONG_TYPE -> TypeTag.LONG + FLOAT_TYPE -> TypeTag.FLOAT + DOUBLE_TYPE -> TypeTag.DOUBLE + VOID_TYPE -> TypeTag.VOID + else -> null + } ?: return null + return TypeIdent(typeTag) + } + + @Suppress("FunctionName") + fun SimpleName(name: String): JCTree.JCExpression = Ident(name(name)) + + fun name(name: String): Name = nameTable.fromString(name) + + companion object { + internal fun preRegister(context: Context) { + context.put(treeMakerKey, Context.Factory { Kapt4TreeMaker(it) }) + } + } +} \ No newline at end of file diff --git a/plugins/kapt4/src/org/jetbrains/kotlin/kapt4/parseParameters.kt b/plugins/kapt4/src/org/jetbrains/kotlin/kapt4/parseParameters.kt new file mode 100644 index 00000000000..23f2ab40f9f --- /dev/null +++ b/plugins/kapt4/src/org/jetbrains/kotlin/kapt4/parseParameters.kt @@ -0,0 +1,26 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +@file:Suppress("UnstableApiUsage") + +package org.jetbrains.kotlin.kapt4 + +import com.intellij.psi.JvmPsiConversionHelper +import com.intellij.psi.PsiAnnotation +import com.intellij.psi.PsiMethod +import com.intellij.psi.PsiType + +internal class ParameterInfo( + val name: String, + val type: PsiType, + val annotations: List, +) + +internal fun PsiMethod.getParametersInfo(): List { + val typeConverter = JvmPsiConversionHelper.getInstance(project) + return this.parameterList.parameters.map { + ParameterInfo(it.name, typeConverter.convertType(it.type), it.annotations.asList()) + } +} diff --git a/plugins/kapt4/src/org/jetbrains/kotlin/kapt4/utils.kt b/plugins/kapt4/src/org/jetbrains/kotlin/kapt4/utils.kt new file mode 100644 index 00000000000..5c7ebff8226 --- /dev/null +++ b/plugins/kapt4/src/org/jetbrains/kotlin/kapt4/utils.kt @@ -0,0 +1,229 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.kapt4 + +import com.intellij.lang.jvm.JvmModifier +import com.intellij.psi.* +import com.intellij.psi.util.ClassUtil +import com.intellij.psi.util.PsiTypesUtil +import com.intellij.psi.util.PsiUtil +import org.jetbrains.kotlin.builtins.StandardNames +import org.jetbrains.org.objectweb.asm.Opcodes + +internal val PsiModifierListOwner.isPublic: Boolean get() = hasModifier(JvmModifier.PUBLIC) +internal val PsiModifierListOwner.isPrivate: Boolean get() = hasModifier(JvmModifier.PRIVATE) +internal val PsiModifierListOwner.isProtected: Boolean get() = hasModifier(JvmModifier.PROTECTED) + +internal val PsiModifierListOwner.isFinal: Boolean get() = hasModifier(JvmModifier.FINAL) +internal val PsiModifierListOwner.isAbstract: Boolean get() = hasModifier(JvmModifier.ABSTRACT) + +internal val PsiModifierListOwner.isStatic: Boolean get() = hasModifier(JvmModifier.STATIC) +internal val PsiModifierListOwner.isVolatile: Boolean get() = hasModifier(JvmModifier.VOLATILE) +internal val PsiModifierListOwner.isSynchronized: Boolean get() = hasModifier(JvmModifier.SYNCHRONIZED) +internal val PsiModifierListOwner.isNative: Boolean get() = hasModifier(JvmModifier.NATIVE) +internal val PsiModifierListOwner.isStrict: Boolean get() = hasModifier(JvmModifier.STRICTFP) +internal val PsiModifierListOwner.isTransient: Boolean get() = hasModifier(JvmModifier.TRANSIENT) + +internal typealias JavacList = com.sun.tools.javac.util.List + +internal inline fun mapJList(values: Array?, f: (T) -> R?): JavacList { + return mapJList(values?.asList(), f) +} + +internal inline fun mapJList(values: Iterable?, f: (T) -> R?): JavacList { + if (values == null) return JavacList.nil() + + var result = JavacList.nil() + for (item in values) { + f(item)?.let { result = result.append(it) } + } + return result +} + +internal inline fun mapJListIndexed(values: Iterable?, f: (Int, T) -> R?): JavacList { + if (values == null) return JavacList.nil() + + var result = JavacList.nil() + values.forEachIndexed { index, item -> + f(index, item)?.let { result = result.append(it) } + } + return result +} + +internal operator fun JavacList.plus(other: JavacList): JavacList { + return this.appendList(other) +} + +internal val PsiMethod.signature: String + get() = ClassUtil.getAsmMethodSignature(this) + +internal val PsiField.signature: String + get() = getAsmFieldSignature(this) + +private fun getAsmFieldSignature(field: PsiField): String { + return ClassUtil.getBinaryPresentation(field.type) +} + +internal val PsiType.qualifiedName: String + get() = qualifiedNameOrNull ?: canonicalText.replace("""<.*>""".toRegex(), "") + +internal val PsiType.qualifiedNameOrNull: String? + get() { + if (this is PsiPrimitiveType) return name + if (this is PsiWildcardType) return this.bound?.qualifiedNameOrNull + return when (val resolvedClass = resolvedClass) { + is PsiTypeParameter -> resolvedClass.name + else -> resolvedClass?.qualifiedName + } + } + +internal val PsiType.simpleNameOrNull: String? + get() { + if (this is PsiPrimitiveType) return name + return when (val resolvedClass = resolvedClass) { + is PsiTypeParameter -> resolvedClass.name + else -> resolvedClass?.name + } + } + +internal val PsiClass.defaultType: PsiType + get() = PsiTypesUtil.getClassType(this) + +internal val PsiType.resolvedClass: PsiClass? + get() = (this as? PsiClassType)?.resolve() + +internal val PsiModifierListOwner.accessFlags: Long + get() = when (this) { + is PsiClass -> computeClassAccessFlags(this) + is PsiMethod -> computeMethodAccessFlags(this) + is PsiField -> computeFieldAccessFlags(this) + else -> 0 + }.toLong() + +private fun computeCommonAccessFlags(declaration: PsiModifierListOwner): Int { + /* + * int ACC_STATIC = 0x0008; // field, method; class isn't mentioned but actually used + * int ACC_PUBLIC = 0x0001; // class, field, method + * int ACC_PRIVATE = 0x0002; // class, field, method + * int ACC_PROTECTED = 0x0004; // class, field, method + * int ACC_FINAL = 0x0010; // class, field, method, parameter + * int ACC_DEPRECATED = 0x20000; // class, field, method + */ + var access = 0 + val visibilityFlag = when { + declaration.isPublic -> Opcodes.ACC_PUBLIC + declaration.isPrivate -> Opcodes.ACC_PRIVATE + declaration.isProtected -> Opcodes.ACC_PROTECTED + else -> 0 + } + access = access or visibilityFlag + if (declaration.isFinal) { + access = access or Opcodes.ACC_FINAL + } + if (declaration.annotations.any { it.hasQualifiedName(StandardNames.FqNames.deprecated.asString()) }) { + access = access or Opcodes.ACC_DEPRECATED + } + if (declaration.isStatic) { + access = access or Opcodes.ACC_STATIC + } + return access +} + +private fun computeClassAccessFlags(klass: PsiClass): Int { + /* + * int ACC_INTERFACE = 0x0200; // class + * int ACC_ABSTRACT = 0x0400; // class, method + * int ACC_ANNOTATION = 0x2000; // class + * int ACC_ENUM = 0x4000; // class(?) field inner + * int ACC_RECORD = 0x10000; // class + */ + var access = computeCommonAccessFlags(klass) + val classKindFlag = when { + klass.isInterface -> Opcodes.ACC_INTERFACE + klass.isEnum -> { + // enum can not be final + access = access and Opcodes.ACC_FINAL.inv() + Opcodes.ACC_ENUM + } + + klass.isRecord -> Opcodes.ACC_RECORD + else -> 0 + } + access = access or classKindFlag + if (klass.isAnnotationType) { + access = access or Opcodes.ACC_ANNOTATION + } + if (klass.isAbstract) { + access = access or Opcodes.ACC_ABSTRACT + } + return access +} + +private fun computeMethodAccessFlags(method: PsiMethod): Int { + /* + * int ACC_SYNCHRONIZED = 0x0020; // method + * int ACC_VARARGS = 0x0080; // method + * int ACC_NATIVE = 0x0100; // method + * int ACC_ABSTRACT = 0x0400; // class, method + * int ACC_STRICT = 0x0800; // method + */ + var access = computeCommonAccessFlags(method) + + if (method.isSynchronized) { + access = access or Opcodes.ACC_SYNCHRONIZED + } + if (method.isVarArgs) { + access = access or Opcodes.ACC_VARARGS + } + if (method.isNative) { + access = access or Opcodes.ACC_NATIVE + } + if (method.isAbstract) { + access = access or Opcodes.ACC_ABSTRACT + } + if (method.isStrict) { + access = access or Opcodes.ACC_STRICT + } + return access +} + +private fun computeFieldAccessFlags(field: PsiField): Int { + /* + * int ACC_VOLATILE = 0x0040; // field + * int ACC_TRANSIENT = 0x0080; // field + * int ACC_ENUM = 0x4000; // class(?) field inner + */ + var access = computeCommonAccessFlags(field) + if (field.isVolatile) { + access = access or Opcodes.ACC_VOLATILE + } + if (field.isTransient) { + access = access or Opcodes.ACC_TRANSIENT + } + if (field is PsiEnumConstant) { + access = access or Opcodes.ACC_ENUM + } + return access +} + +internal val PsiClass.qualifiedNameWithDollars: String? + get() { + val packageName = PsiUtil.getPackageName(this) ?: return null + if (packageName.isBlank()) { + return qualifiedName?.replace(".", "$") ?: return null + } + + val qualifiedName = this.qualifiedName ?: return null + val className = qualifiedName.substringAfter("$packageName.") + val classNameWithDollars = className.replace(".", "$") + return "$packageName.$classNameWithDollars" + } + +private const val LONG_DEPRECATED = Opcodes.ACC_DEPRECATED.toLong() +private const val LONG_ENUM = Opcodes.ACC_ENUM.toLong() + +internal fun isDeprecated(access: Long) = (access and LONG_DEPRECATED) != 0L +internal fun isEnum(access: Long) = (access and LONG_ENUM) != 0L \ No newline at end of file diff --git a/plugins/kapt4/test/org/jetbrains/kotlin/kapt4/AbstractKotlinKaptContextTestBase.kt b/plugins/kapt4/test/org/jetbrains/kotlin/kapt4/AbstractKotlinKaptContextTestBase.kt new file mode 100644 index 00000000000..e14c8934b06 --- /dev/null +++ b/plugins/kapt4/test/org/jetbrains/kotlin/kapt4/AbstractKotlinKaptContextTestBase.kt @@ -0,0 +1,52 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.kapt4 + +import org.jetbrains.kotlin.kapt3.test.* +import org.jetbrains.kotlin.kapt3.test.KaptTestDirectives.MAP_DIAGNOSTIC_LOCATIONS +import org.jetbrains.kotlin.platform.jvm.JvmPlatforms +import org.jetbrains.kotlin.test.TargetBackend +import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder +import org.jetbrains.kotlin.test.directives.ConfigurationDirectives.WITH_STDLIB +import org.jetbrains.kotlin.test.model.DependencyKind +import org.jetbrains.kotlin.test.model.FrontendKinds +import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerWithTargetBackendTest +import org.jetbrains.kotlin.test.services.configuration.CommonEnvironmentConfigurator +import org.jetbrains.kotlin.test.services.configuration.JvmEnvironmentConfigurator + +open class AbstractKotlinKapt4ContextTest : AbstractKotlinKapt4ContextTestBase(TargetBackend.JVM_IR) + +abstract class AbstractKotlinKapt4ContextTestBase( + targetBackend: TargetBackend +) : AbstractKotlinCompilerWithTargetBackendTest(targetBackend) { + override fun TestConfigurationBuilder.configuration() { + globalDefaults { + frontend = FrontendKinds.FIR + targetPlatform = JvmPlatforms.defaultJvmPlatform + dependencyKind = DependencyKind.Binary + } + + defaultDirectives { + +MAP_DIAGNOSTIC_LOCATIONS + +WITH_STDLIB + } + + useConfigurators( + ::CommonEnvironmentConfigurator, + ::JvmEnvironmentConfigurator, + ::KaptEnvironmentConfigurator, + ::Kapt4EnvironmentConfigurator, + ) + + facadeStep(::Kapt4Facade) + + handlersStep(Kapt4ContextBinaryArtifact.Kind) { + useHandlers(::Kapt4Handler) + } + + useAfterAnalysisCheckers(::TemporaryKapt4Suppressor) + } +} diff --git a/plugins/kapt4/test/org/jetbrains/kotlin/kapt4/Kapt4EnvironmentConfigurator.kt b/plugins/kapt4/test/org/jetbrains/kotlin/kapt4/Kapt4EnvironmentConfigurator.kt new file mode 100644 index 00000000000..32365aab7be --- /dev/null +++ b/plugins/kapt4/test/org/jetbrains/kotlin/kapt4/Kapt4EnvironmentConfigurator.kt @@ -0,0 +1,27 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.kapt4 + +import org.jetbrains.kotlin.config.AnalysisFlag +import org.jetbrains.kotlin.config.JvmAnalysisFlags +import org.jetbrains.kotlin.config.JvmDefaultMode +import org.jetbrains.kotlin.config.LanguageVersion +import org.jetbrains.kotlin.test.directives.model.DirectivesContainer +import org.jetbrains.kotlin.test.directives.model.RegisteredDirectives +import org.jetbrains.kotlin.test.services.EnvironmentConfigurator +import org.jetbrains.kotlin.test.services.TestServices + +class Kapt4EnvironmentConfigurator(testServices: TestServices) : EnvironmentConfigurator(testServices) { + override fun provideAdditionalAnalysisFlags( + directives: RegisteredDirectives, + languageVersion: LanguageVersion, + ): Map, Any?> = mapOf( + JvmAnalysisFlags.generatePropertyAnnotationsMethods to true, + JvmAnalysisFlags.jvmDefaultMode to JvmDefaultMode.ALL_INCOMPATIBLE + ) + + override val directiveContainers: List = listOf(Kapt4TestDirectives) +} \ No newline at end of file diff --git a/plugins/kapt4/test/org/jetbrains/kotlin/kapt4/Kapt4Facade.kt b/plugins/kapt4/test/org/jetbrains/kotlin/kapt4/Kapt4Facade.kt new file mode 100644 index 00000000000..a1a5aa35280 --- /dev/null +++ b/plugins/kapt4/test/org/jetbrains/kotlin/kapt4/Kapt4Facade.kt @@ -0,0 +1,114 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.kapt4 + +import com.intellij.mock.MockProject +import com.intellij.openapi.Disposable +import org.jetbrains.kotlin.analysis.api.KtAnalysisApiInternals +import org.jetbrains.kotlin.analysis.api.lifetime.KtLifetimeTokenProvider +import org.jetbrains.kotlin.analysis.api.lifetime.KtReadActionConfinementLifetimeTokenProvider +import org.jetbrains.kotlin.analysis.api.session.KtAnalysisSessionProvider +import org.jetbrains.kotlin.analysis.api.standalone.buildStandaloneAnalysisAPISession +import org.jetbrains.kotlin.asJava.classes.KtLightClass +import org.jetbrains.kotlin.asJava.findFacadeClass +import org.jetbrains.kotlin.asJava.toLightClass +import org.jetbrains.kotlin.base.kapt3.KaptOptions +import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoots +import org.jetbrains.kotlin.cli.jvm.config.addJavaSourceRoots +import org.jetbrains.kotlin.config.CompilerConfiguration +import org.jetbrains.kotlin.kapt3.base.util.WriterBackedKaptLogger +import org.jetbrains.kotlin.kapt3.test.KaptMessageCollectorProvider +import org.jetbrains.kotlin.kapt3.test.kaptOptionsProvider +import org.jetbrains.kotlin.psi.KtClassOrObject +import org.jetbrains.kotlin.psi.KtFile +import org.jetbrains.kotlin.test.model.* +import org.jetbrains.kotlin.test.services.* +import java.io.File + +internal class Kapt4Facade(private val testServices: TestServices) : + AbstractTestFacade() { + override val inputKind: TestArtifactKind + get() = SourcesKind + override val outputKind: TestArtifactKind + get() = Kapt4ContextBinaryArtifact.Kind + + override val additionalServices: List + get() = listOf(service(::KaptMessageCollectorProvider)) + + override fun transform(module: TestModule, inputArtifact: ResultingArtifact.Source): Kapt4ContextBinaryArtifact { + val configurationProvider = testServices.compilerConfigurationProvider + + val configuration = configurationProvider.getCompilerConfiguration(module) + configuration.addKotlinSourceRoots(module.files.filter { it.isKtFile }.map { it.realFile().absolutePath }) + val options = testServices.kaptOptionsProvider[module] + val (context, stubMap) = run( + configuration, + options, + testServices.applicationDisposableProvider.getApplicationRootDisposable(), + configurationProvider.testRootDisposable + ) + return Kapt4ContextBinaryArtifact(context, stubMap.values.filterNotNull()) + } + + private fun TestFile.realFile(): File { + return testServices.sourceFileProvider.getRealFileForSourceFile(this) + } + + override fun shouldRunAnalysis(module: TestModule): Boolean { + return true + } +} + +@OptIn(KtAnalysisApiInternals::class) +private fun run( + configuration: CompilerConfiguration, + options: KaptOptions, + applicationDisposable: Disposable, + projectDisposable: Disposable, +): Pair> { + val standaloneAnalysisAPISession = buildStandaloneAnalysisAPISession(applicationDisposable, projectDisposable) { + (project as MockProject).registerService( + KtLifetimeTokenProvider::class.java, + KtReadActionConfinementLifetimeTokenProvider::class.java + ) + @Suppress("DEPRECATION") + buildKtModuleProviderByCompilerConfiguration(configuration) + } + val (module, psiFiles) = standaloneAnalysisAPISession.modulesWithFiles.entries.single() + val ktFiles = psiFiles.filterIsInstance() + + val lightClasses = buildSet { + ktFiles.flatMapTo(this) { file -> + file.children.filterIsInstance().mapNotNull { + it.toLightClass() + } + } + ktFiles.mapNotNullTo(this) { ktFile -> ktFile.findFacadeClass() }.distinct() + } + + return KtAnalysisSessionProvider.getInstance(module.project).analyze(module) { + val context = Kapt4ContextForStubGeneration( + options, + withJdk = false, + WriterBackedKaptLogger(isVerbose = false), + this@analyze, + lightClasses + ) + val generator = with(context) { Kapt4StubGenerator() } + context to generator.generateStubs() + } +} + +internal data class Kapt4ContextBinaryArtifact( + internal val kaptContext: Kapt4ContextForStubGeneration, + internal val kaptStubs: List +) : ResultingArtifact.Binary() { + object Kind : BinaryKind("KaptArtifact") + + override val kind: BinaryKind + get() = Kind +} + diff --git a/plugins/kapt4/test/org/jetbrains/kotlin/kapt4/Kapt4Handler.kt b/plugins/kapt4/test/org/jetbrains/kotlin/kapt4/Kapt4Handler.kt new file mode 100644 index 00000000000..c1436030db5 --- /dev/null +++ b/plugins/kapt4/test/org/jetbrains/kotlin/kapt4/Kapt4Handler.kt @@ -0,0 +1,177 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.kapt4 + +import com.intellij.openapi.util.text.StringUtil +import com.sun.tools.javac.comp.CompileStates +import com.sun.tools.javac.tree.JCTree +import com.sun.tools.javac.util.JCDiagnostic +import com.sun.tools.javac.util.List +import com.sun.tools.javac.util.Log +import org.jetbrains.kotlin.kapt3.base.javac.KaptJavaLogBase +import org.jetbrains.kotlin.kapt3.base.parseJavaFiles +import org.jetbrains.kotlin.kapt3.javac.KaptJavaFileObject +import org.jetbrains.kotlin.kapt3.test.KaptTestDirectives +import org.jetbrains.kotlin.kapt3.test.KaptTestDirectives.EXPECTED_ERROR +import org.jetbrains.kotlin.kapt3.test.handlers.ClassFileToSourceKaptStubHandler +import org.jetbrains.kotlin.kapt3.test.handlers.removeMetadataAnnotationContents +import org.jetbrains.kotlin.kapt3.test.messageCollectorProvider +import org.jetbrains.kotlin.kapt3.util.prettyPrint +import org.jetbrains.kotlin.test.Assertions +import org.jetbrains.kotlin.test.model.AnalysisHandler +import org.jetbrains.kotlin.test.model.TestArtifactKind +import org.jetbrains.kotlin.test.model.TestModule +import org.jetbrains.kotlin.test.services.TestServices +import org.jetbrains.kotlin.test.services.getRealJavaFiles +import org.jetbrains.kotlin.test.services.sourceFileProvider +import org.jetbrains.kotlin.test.util.trimTrailingWhitespacesAndAddNewlineAtEOF +import org.jetbrains.kotlin.test.utils.withExtension +import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance +import java.io.File +import java.util.* + +internal class Kapt4Handler(testServices: TestServices) : AnalysisHandler( + testServices, + failureDisablesNextSteps = true, + doNotRunIfThereWerePreviousFailures = true +) { + override val artifactKind: TestArtifactKind + get() = Kapt4ContextBinaryArtifact.Kind + + override fun processModule(module: TestModule, info: Kapt4ContextBinaryArtifact) { + val validate = KaptTestDirectives.NO_VALIDATION !in module.directives + + val (kaptContext) = info + val convertedFiles = getJavaFiles(info, module) + kaptContext.javaLog.interceptorData.files = convertedFiles.associateBy { it.sourceFile } + if (validate) kaptContext.compiler.enterTrees(convertedFiles) + + val actualRaw = convertedFiles + .sortedBy { it.sourceFile.name } + .joinToString(ClassFileToSourceKaptStubHandler.FILE_SEPARATOR) { it.prettyPrint(kaptContext.context) } + + val actual = StringUtil.convertLineSeparators(actualRaw.trim { it <= ' ' }) + .trimTrailingWhitespacesAndAddNewlineAtEOF() + .let { removeMetadataAnnotationContents(it) } + + assertions.assertAll( + { assertions.checkTxt(module, actual) }, + { + if (kaptContext.compiler.shouldStop(CompileStates.CompileState.ENTER)) { + checkJavaCompilerErrors(module, kaptContext, actual) + } + } + ) + } + + private fun checkJavaCompilerErrors( + module: TestModule, + kaptContext: Kapt4ContextForStubGeneration, + actualDump: String + ) { + val expectedErrors = (module.directives[EXPECTED_ERROR] + module.directives[Kapt4TestDirectives.EXPECTED_ERROR_K2]).sorted() + val log = Log.instance(kaptContext.context) as KaptJavaLogBase + + val actualErrors = log.reportedDiagnostics + .filter { it.type == JCDiagnostic.DiagnosticType.ERROR } + .map { + // Unfortunately, we can't use the file name as it can contain temporary prefix + val name = it.source?.name?.substringAfterLast("/") ?: "" + val kind = when (name.substringAfterLast(".").lowercase()) { + "kt" -> "kotlin" + "java" -> "java" + else -> "other" + } + + val javaLocation = "($kind:${it.lineNumber}:${it.columnNumber}) " + javaLocation + it.getMessage(Locale.US).lines().first() + } + .sorted() + + log.flush() + + val lineSeparator = System.getProperty("line.separator") + val actualErrorsStr = actualErrors.joinToString(lineSeparator) { it.toDirectiveView() } + + if (expectedErrors.isEmpty()) { + assertions.fail { "There were errors during analysis:\n$actualErrorsStr\n\nStubs:\n\n$actualDump" } + } else { + val expectedErrorsStr = expectedErrors.joinToString(lineSeparator) { it.toDirectiveView() } + if (expectedErrorsStr != actualErrorsStr) { + assertions.assertEquals(expectedErrorsStr, actualErrorsStr) { + System.err.println(testServices.messageCollectorProvider.getErrorStream(module).toString("UTF8")) + "Expected error matching failed" + } + } + } + } + + private fun getJavaFiles( + info: Kapt4ContextBinaryArtifact, + module: TestModule + ): List { + val (kaptContext, kaptStubs) = info + val convertedFiles = kaptStubs.mapIndexed { index, stub -> + val sourceFile = createTempJavaFile("stub$index.java", stub.file.prettyPrint(kaptContext.context)) + stub.writeMetadataIfNeeded(forSource = sourceFile) + sourceFile + } + + val javaFiles = testServices.sourceFileProvider.getRealJavaFiles(module) + val allJavaFiles = javaFiles + convertedFiles + + // A workaround needed for Javac to parse files correctly even if errors were already reported + // If nerrors > 0, "parseFiles()" returns the empty list + val oldErrorCount = kaptContext.compiler.log.nerrors + kaptContext.compiler.log.nerrors = 0 + + try { + val parsedJavaFiles = kaptContext.parseJavaFiles(allJavaFiles) + + for (tree in parsedJavaFiles) { + val actualFile = File(tree.sourceFile.toUri()) + + // By default, JavaFileObject.getName() returns the absolute path to the file. + // In our test, such a path will be temporary, so the comparison against it will lead to flaky tests. + tree.sourcefile = KaptJavaFileObject(tree, tree.defs.firstIsInstance(), actualFile) + } + + return parsedJavaFiles + } finally { + kaptContext.compiler.log.nerrors = oldErrorCount + } + } + + override fun processAfterAllModules(someAssertionWasFailed: Boolean) {} + + private fun createTempJavaFile(name: String, text: String): File { + return testServices.sourceFileProvider.javaSourceDirectory.resolve(name).also { + it.writeText(text) + } + } + + private fun String.toDirectiveView(): String = "// ${EXPECTED_ERROR.name}: $this" +} + +fun Assertions.checkTxt(module: TestModule, actual: String) { + val testDataFile = module.files.first().originalFile + val firFile = testDataFile.withExtension("fir.txt") + val irFile = testDataFile.withExtension("ir.txt") + val txtFile = testDataFile.withExtension("txt") + val expectedFile = sequenceOf(firFile, irFile, txtFile) + .firstOrNull { it.exists() } ?: firFile + + assertEqualsToFile(expectedFile, actual) + if (firFile.exists()) { + if (irFile.exists()) { + if (irFile.readText() == firFile.readText()) { + fail { ".fir.txt and .ir.txt golden files are identical. Remove $firFile." } + } + } else if (txtFile.exists() && txtFile.readText() == firFile.readText()) { + fail { ".fir.txt and .txt golden files are identical. Remove $firFile." } + } + } +} \ No newline at end of file diff --git a/plugins/kapt4/test/org/jetbrains/kotlin/kapt4/Kapt4TestDirectives.kt b/plugins/kapt4/test/org/jetbrains/kotlin/kapt4/Kapt4TestDirectives.kt new file mode 100644 index 00000000000..8bf159e5df3 --- /dev/null +++ b/plugins/kapt4/test/org/jetbrains/kotlin/kapt4/Kapt4TestDirectives.kt @@ -0,0 +1,12 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.kapt4 + +import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer + +object Kapt4TestDirectives : SimpleDirectivesContainer() { + val EXPECTED_ERROR_K2 by stringDirective("Expected K2-specific error", multiLine = true) +} \ No newline at end of file diff --git a/plugins/kapt4/test/org/jetbrains/kotlin/kapt4/TemporaryKapt4Suppressor.kt b/plugins/kapt4/test/org/jetbrains/kotlin/kapt4/TemporaryKapt4Suppressor.kt new file mode 100644 index 00000000000..64860c9cb5e --- /dev/null +++ b/plugins/kapt4/test/org/jetbrains/kotlin/kapt4/TemporaryKapt4Suppressor.kt @@ -0,0 +1,39 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.kapt4 + +import org.jetbrains.kotlin.kapt4.Kapt4Directives.FIR_BLOCKED +import org.jetbrains.kotlin.test.WrappedException +import org.jetbrains.kotlin.test.directives.model.Directive +import org.jetbrains.kotlin.test.directives.model.DirectivesContainer +import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer +import org.jetbrains.kotlin.test.model.AfterAnalysisChecker +import org.jetbrains.kotlin.test.services.TestServices +import org.jetbrains.kotlin.test.services.assertions +import org.jetbrains.kotlin.test.services.moduleStructure + +internal class TemporaryKapt4Suppressor(testServices: TestServices) : AfterAnalysisChecker(testServices) { + override val directiveContainers: List + get() = listOf(Kapt4Directives) + + override fun suppressIfNeeded(failedAssertions: List): List { + val hasFailures = failedAssertions.isNotEmpty() + if (suppressedByDirective(FIR_BLOCKED, hasFailures)) return emptyList() + return failedAssertions + } + + private fun suppressedByDirective(directive: Directive, hasFailures: Boolean): Boolean { + val hasDirective = testServices.moduleStructure.modules.any { directive in it.directives } + if (hasDirective && !hasFailures) { + testServices.assertions.fail { "Test passes, remove $directive directive" } + } + return hasDirective + } +} + +object Kapt4Directives : SimpleDirectivesContainer() { + val FIR_BLOCKED by stringDirective("Blocked by light classes") +} diff --git a/plugins/kapt4/tests-gen/org/jetbrains/kotlin/kapt4/KotlinKapt4ContextTestGenerated.java b/plugins/kapt4/tests-gen/org/jetbrains/kotlin/kapt4/KotlinKapt4ContextTestGenerated.java new file mode 100644 index 00000000000..0d605a8bac0 --- /dev/null +++ b/plugins/kapt4/tests-gen/org/jetbrains/kotlin/kapt4/KotlinKapt4ContextTestGenerated.java @@ -0,0 +1,693 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.kapt4; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.util.KtTestUtil; +import org.jetbrains.kotlin.test.TargetBackend; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.GenerateTestsKt}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter") +@TestDataPath("$PROJECT_ROOT") +public class KotlinKapt4ContextTestGenerated extends AbstractKotlinKapt4ContextTest { + @Test + @TestMetadata("abstractEnum.kt") + public void testAbstractEnum() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/abstractEnum.kt"); + } + + @Test + @TestMetadata("abstractMethods.kt") + public void testAbstractMethods() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/abstractMethods.kt"); + } + + @Test + @TestMetadata("aliasedImports.kt") + public void testAliasedImports() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/aliasedImports.kt"); + } + + @Test + public void testAllFilesPresentInConverter() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("annotationWithFqNames.kt") + public void testAnnotationWithFqNames() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/annotationWithFqNames.kt"); + } + + @Test + @TestMetadata("annotations.kt") + public void testAnnotations() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/annotations.kt"); + } + + @Test + @TestMetadata("annotations2.kt") + public void testAnnotations2() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/annotations2.kt"); + } + + @Test + @TestMetadata("annotations3.kt") + public void testAnnotations3() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/annotations3.kt"); + } + + @Test + @TestMetadata("annotationsWithConstants.kt") + public void testAnnotationsWithConstants() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/annotationsWithConstants.kt"); + } + + @Test + @TestMetadata("annotationsWithTargets.kt") + public void testAnnotationsWithTargets() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/annotationsWithTargets.kt"); + } + + @Test + @TestMetadata("anonymousDelegate.kt") + public void testAnonymousDelegate() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/anonymousDelegate.kt"); + } + + @Test + @TestMetadata("anonymousInitializer.kt") + public void testAnonymousInitializer() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/anonymousInitializer.kt"); + } + + @Test + @TestMetadata("anonymousObjectInEnumSuperConstructor.kt") + public void testAnonymousObjectInEnumSuperConstructor() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/anonymousObjectInEnumSuperConstructor.kt"); + } + + @Test + @TestMetadata("comments.kt") + public void testComments() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/comments.kt"); + } + + @Test + @TestMetadata("commentsRemoved.kt") + public void testCommentsRemoved() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/commentsRemoved.kt"); + } + + @Test + @TestMetadata("cyrillicClassName.kt") + public void testCyrillicClassName() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/cyrillicClassName.kt"); + } + + @Test + @TestMetadata("dataClass.kt") + public void testDataClass() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/dataClass.kt"); + } + + @Test + @TestMetadata("defaultImpls.kt") + public void testDefaultImpls() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/defaultImpls.kt"); + } + + @Test + @TestMetadata("defaultImplsWithTypeParameters.kt") + public void testDefaultImplsWithTypeParameters() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/defaultImplsWithTypeParameters.kt"); + } + + @Test + @TestMetadata("defaultPackage.kt") + public void testDefaultPackage() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/defaultPackage.kt"); + } + + @Test + @TestMetadata("defaultPackageCorrectErrorTypes.kt") + public void testDefaultPackageCorrectErrorTypes() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/defaultPackageCorrectErrorTypes.kt"); + } + + @Test + @TestMetadata("defaultParameterValueOff.kt") + public void testDefaultParameterValueOff() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/defaultParameterValueOff.kt"); + } + + @Test + @TestMetadata("defaultParameterValueOn.kt") + public void testDefaultParameterValueOn() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/defaultParameterValueOn.kt"); + } + + @Test + @TestMetadata("delegateCorrectErrorTypes.kt") + public void testDelegateCorrectErrorTypes() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/delegateCorrectErrorTypes.kt"); + } + + @Test + @TestMetadata("delegateToList.kt") + public void testDelegateToList() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/delegateToList.kt"); + } + + @Test + @TestMetadata("delegatedProperties.kt") + public void testDelegatedProperties() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/delegatedProperties.kt"); + } + + @Test + @TestMetadata("delegationAndCompanionObject.kt") + public void testDelegationAndCompanionObject() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/delegationAndCompanionObject.kt"); + } + + @Test + @TestMetadata("delegationToAnonymousObject.kt") + public void testDelegationToAnonymousObject() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/delegationToAnonymousObject.kt"); + } + + @Test + @TestMetadata("deprecated.kt") + public void testDeprecated() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/deprecated.kt"); + } + + @Test + @TestMetadata("enumImports.kt") + public void testEnumImports() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/enumImports.kt"); + } + + @Test + @TestMetadata("enumInCompanion.kt") + public void testEnumInCompanion() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/enumInCompanion.kt"); + } + + @Test + @TestMetadata("enumSecondaryConstructor.kt") + public void testEnumSecondaryConstructor() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/enumSecondaryConstructor.kt"); + } + + @Test + @TestMetadata("enums.kt") + public void testEnums() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/enums.kt"); + } + + @Test + @TestMetadata("errorExtensionReceiver.kt") + public void testErrorExtensionReceiver() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/errorExtensionReceiver.kt"); + } + + @Test + @TestMetadata("errorLocationMapping.kt") + public void testErrorLocationMapping() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/errorLocationMapping.kt"); + } + + @Test + @TestMetadata("errorSuperclass.kt") + public void testErrorSuperclass() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/errorSuperclass.kt"); + } + + @Test + @TestMetadata("errorSuperclassCorrectErrorTypes.kt") + public void testErrorSuperclassCorrectErrorTypes() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/errorSuperclassCorrectErrorTypes.kt"); + } + + @Test + @TestMetadata("fileFacadeJvmName.kt") + public void testFileFacadeJvmName() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/fileFacadeJvmName.kt"); + } + + @Test + @TestMetadata("functions.kt") + public void testFunctions() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/functions.kt"); + } + + @Test + @TestMetadata("genericParameters.kt") + public void testGenericParameters() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/genericParameters.kt"); + } + + @Test + @TestMetadata("genericRawSignatures.kt") + public void testGenericRawSignatures() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/genericRawSignatures.kt"); + } + + @Test + @TestMetadata("genericSimple.kt") + public void testGenericSimple() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/genericSimple.kt"); + } + + @Test + @TestMetadata("ignoredMembers.kt") + public void testIgnoredMembers() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/ignoredMembers.kt"); + } + + @Test + @TestMetadata("implicitReturnTypes.kt") + public void testImplicitReturnTypes() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/implicitReturnTypes.kt"); + } + + @Test + @TestMetadata("importsForErrorTypes.kt") + public void testImportsForErrorTypes() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/importsForErrorTypes.kt"); + } + + @Test + @TestMetadata("importsKt22083.kt") + public void testImportsKt22083() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/importsKt22083.kt"); + } + + @Test + @TestMetadata("incorrectDelegate.kt") + public void testIncorrectDelegate() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/incorrectDelegate.kt"); + } + + @Test + @TestMetadata("inheritanceSimple.kt") + public void testInheritanceSimple() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/inheritanceSimple.kt"); + } + + @Test + @TestMetadata("inlineClasses.kt") + public void testInlineClasses() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/inlineClasses.kt"); + } + + @Test + @TestMetadata("innerClassesWithTypeParameters.kt") + public void testInnerClassesWithTypeParameters() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/innerClassesWithTypeParameters.kt"); + } + + @Test + @TestMetadata("interfaceImplementation.kt") + public void testInterfaceImplementation() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/interfaceImplementation.kt"); + } + + @Test + @TestMetadata("invalidFieldName.kt") + public void testInvalidFieldName() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/invalidFieldName.kt"); + } + + @Test + @TestMetadata("javaKeywords.kt") + public void testJavaKeywords() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/javaKeywords.kt"); + } + + @Test + @TestMetadata("javaKeywordsInPackageNames.kt") + public void testJavaKeywordsInPackageNames() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/javaKeywordsInPackageNames.kt"); + } + + @Test + @TestMetadata("javadoc.kt") + public void testJavadoc() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/javadoc.kt"); + } + + @Test + @TestMetadata("jvmDefaultAll.kt") + public void testJvmDefaultAll() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/jvmDefaultAll.kt"); + } + + @Test + @TestMetadata("jvmDefaultAllCompatibility.kt") + public void testJvmDefaultAllCompatibility() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/jvmDefaultAllCompatibility.kt"); + } + + @Test + @TestMetadata("jvmOverloads.kt") + public void testJvmOverloads() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/jvmOverloads.kt"); + } + + @Test + @TestMetadata("jvmRepeatableAnnotation.kt") + public void testJvmRepeatableAnnotation() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/jvmRepeatableAnnotation.kt"); + } + + @Test + @TestMetadata("jvmStatic.kt") + public void testJvmStatic() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/jvmStatic.kt"); + } + + @Test + @TestMetadata("jvmStaticFieldInParent.kt") + public void testJvmStaticFieldInParent() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/jvmStaticFieldInParent.kt"); + } + + @Test + @TestMetadata("kt14996.kt") + public void testKt14996() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/kt14996.kt"); + } + + @Test + @TestMetadata("kt14997.kt") + public void testKt14997() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/kt14997.kt"); + } + + @Test + @TestMetadata("kt14998.kt") + public void testKt14998() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/kt14998.kt"); + } + + @Test + @TestMetadata("kt15145.kt") + public void testKt15145() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/kt15145.kt"); + } + + @Test + @TestMetadata("kt17567.kt") + public void testKt17567() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/kt17567.kt"); + } + + @Test + @TestMetadata("kt18377.kt") + public void testKt18377() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/kt18377.kt"); + } + + @Test + @TestMetadata("kt18682.kt") + public void testKt18682() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/kt18682.kt"); + } + + @Test + @TestMetadata("kt19700.kt") + public void testKt19700() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/kt19700.kt"); + } + + @Test + @TestMetadata("kt19750.kt") + public void testKt19750() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/kt19750.kt"); + } + + @Test + @TestMetadata("kt24272.kt") + public void testKt24272() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/kt24272.kt"); + } + + @Test + @TestMetadata("kt25071.kt") + public void testKt25071() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/kt25071.kt"); + } + + @Test + @TestMetadata("kt27126.kt") + public void testKt27126() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/kt27126.kt"); + } + + @Test + @TestMetadata("kt28306.kt") + public void testKt28306() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/kt28306.kt"); + } + + @Test + @TestMetadata("kt32596.kt") + public void testKt32596() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/kt32596.kt"); + } + + @Test + @TestMetadata("kt34569.kt") + public void testKt34569() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/kt34569.kt"); + } + + @Test + @TestMetadata("kt43786.kt") + public void testKt43786() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/kt43786.kt"); + } + + @Test + @TestMetadata("lazyProperty.kt") + public void testLazyProperty() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/lazyProperty.kt"); + } + + @Test + @TestMetadata("leadingDollars.kt") + public void testLeadingDollars() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/leadingDollars.kt"); + } + + @Test + @TestMetadata("leadingDollars2.kt") + public void testLeadingDollars2() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/leadingDollars2.kt"); + } + + @Test + @TestMetadata("mapEntry.kt") + public void testMapEntry() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/mapEntry.kt"); + } + + @Test + @TestMetadata("maxErrorCount.kt") + public void testMaxErrorCount() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/maxErrorCount.kt"); + } + + @Test + @TestMetadata("methodParameterNames.kt") + public void testMethodParameterNames() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/methodParameterNames.kt"); + } + + @Test + @TestMetadata("methodPropertySignatureClash.kt") + public void testMethodPropertySignatureClash() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/methodPropertySignatureClash.kt"); + } + + @Test + @TestMetadata("modifiers.kt") + public void testModifiers() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/modifiers.kt"); + } + + @Test + @TestMetadata("multifileClass.kt") + public void testMultifileClass() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/multifileClass.kt"); + } + + @Test + @TestMetadata("multifileClassDefaultPackage.kt") + public void testMultifileClassDefaultPackage() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/multifileClassDefaultPackage.kt"); + } + + @Test + @TestMetadata("nestedClasses.kt") + public void testNestedClasses() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/nestedClasses.kt"); + } + + @Test + @TestMetadata("nestedClasses2.kt") + public void testNestedClasses2() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/nestedClasses2.kt"); + } + + @Test + @TestMetadata("nestedClassesNonRootPackage.kt") + public void testNestedClassesNonRootPackage() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/nestedClassesNonRootPackage.kt"); + } + + @Test + @TestMetadata("nonExistentClass.kt") + public void testNonExistentClass() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/nonExistentClass.kt"); + } + + @Test + @TestMetadata("nonExistentClassTypesConversion.kt") + public void testNonExistentClassTypesConversion() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/nonExistentClassTypesConversion.kt"); + } + + @Test + @TestMetadata("nonExistentClassWIthoutCorrection.kt") + public void testNonExistentClassWIthoutCorrection() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/nonExistentClassWIthoutCorrection.kt"); + } + + @Test + @TestMetadata("primitiveTypes.kt") + public void testPrimitiveTypes() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/primitiveTypes.kt"); + } + + @Test + @TestMetadata("properties.kt") + public void testProperties() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/properties.kt"); + } + + @Test + @TestMetadata("propertyAnnotations.kt") + public void testPropertyAnnotations() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/propertyAnnotations.kt"); + } + + @Test + @TestMetadata("recentlyNullable.kt") + public void testRecentlyNullable() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/recentlyNullable.kt"); + } + + @Test + @TestMetadata("repeatableAnnotations.kt") + public void testRepeatableAnnotations() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/repeatableAnnotations.kt"); + } + + @Test + @TestMetadata("secondaryConstructor.kt") + public void testSecondaryConstructor() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/secondaryConstructor.kt"); + } + + @Test + @TestMetadata("severalPackageParts.kt") + public void testSeveralPackageParts() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/severalPackageParts.kt"); + } + + @Test + @TestMetadata("starImports.kt") + public void testStarImports() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/starImports.kt"); + } + + @Test + @TestMetadata("strangeIdentifiers.kt") + public void testStrangeIdentifiers() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/strangeIdentifiers.kt"); + } + + @Test + @TestMetadata("strangeNames.kt") + public void testStrangeNames() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/strangeNames.kt"); + } + + @Test + @TestMetadata("stripMetadata.kt") + public void testStripMetadata() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/stripMetadata.kt"); + } + + @Test + @TestMetadata("superConstructorCall.kt") + public void testSuperConstructorCall() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/superConstructorCall.kt"); + } + + @Test + @TestMetadata("suspendArgName.kt") + public void testSuspendArgName() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/suspendArgName.kt"); + } + + @Test + @TestMetadata("suspendErrorTypes.kt") + public void testSuspendErrorTypes() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/suspendErrorTypes.kt"); + } + + @Test + @TestMetadata("suspendFunctionSupertype.kt") + public void testSuspendFunctionSupertype() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/suspendFunctionSupertype.kt"); + } + + @Test + @TestMetadata("suspendFunctionWithBigArity.kt") + public void testSuspendFunctionWithBigArity() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/suspendFunctionWithBigArity.kt"); + } + + @Test + @TestMetadata("topLevel.kt") + public void testTopLevel() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/topLevel.kt"); + } + + @Test + @TestMetadata("unresolvedDelegateExpression.kt") + public void testUnresolvedDelegateExpression() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/unresolvedDelegateExpression.kt"); + } + + @Test + @TestMetadata("unsafePropertyInitializers.kt") + public void testUnsafePropertyInitializers() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/unsafePropertyInitializers.kt"); + } +}