Add mode to run kapt with JVM IR, use in tests

Currently JVM IR is not supported in kapt, so almost all tests are
failing, and thus are muted with IGNORE_BACKEND.

 #KT-49682
This commit is contained in:
Alexander Udalov
2021-12-08 23:05:43 +01:00
parent d089d27bef
commit ebb9659e03
107 changed files with 251 additions and 98 deletions
@@ -85,6 +85,11 @@ public class JVMConfigurationKeys {
public static final CompilerConfigurationKey<Boolean> IR = public static final CompilerConfigurationKey<Boolean> IR =
CompilerConfigurationKey.create("IR"); CompilerConfigurationKey.create("IR");
// Temporary option to make it possible to test kapt with JVM IR. As soon as all tests start to pass, it can be removed,
// and the backend (old or IR) will be deduced from the compiler arguments provided by the user.
public static final CompilerConfigurationKey<Boolean> USE_KAPT_WITH_JVM_IR =
CompilerConfigurationKey.create("Enable JVM IR for kapt");
public static final CompilerConfigurationKey<Boolean> USE_PSI_CLASS_FILES_READING = public static final CompilerConfigurationKey<Boolean> USE_PSI_CLASS_FILES_READING =
CompilerConfigurationKey.create("use a slower (PSI-based) class files reading implementation"); CompilerConfigurationKey.create("use a slower (PSI-based) class files reading implementation");
@@ -185,9 +185,9 @@ object GenerationUtils {
analysisResult: AnalysisResult, analysisResult: AnalysisResult,
configureGenerationState: GenerationState.Builder.() -> Unit = {}, configureGenerationState: GenerationState.Builder.() -> Unit = {},
): GenerationState { ): GenerationState {
/* Currently Kapt3 only works with the old JVM backend, so disable IR for everything except actual bytecode generation. */
val isIrBackend = val isIrBackend =
classBuilderFactory.classBuilderMode == ClassBuilderMode.FULL && configuration.getBoolean(JVMConfigurationKeys.IR) (classBuilderFactory.classBuilderMode == ClassBuilderMode.FULL && configuration.getBoolean(JVMConfigurationKeys.IR)) ||
configuration.getBoolean(JVMConfigurationKeys.USE_KAPT_WITH_JVM_IR)
val generationState = GenerationState.Builder( val generationState = GenerationState.Builder(
project, classBuilderFactory, analysisResult.moduleDescriptor, analysisResult.bindingContext, project, classBuilderFactory, analysisResult.moduleDescriptor, analysisResult.bindingContext,
files, configuration files, configuration
@@ -13,6 +13,7 @@ dependencies {
api(project(":compiler:frontend")) api(project(":compiler:frontend"))
api(project(":compiler:frontend.java")) api(project(":compiler:frontend.java"))
api(project(":compiler:plugin-api")) api(project(":compiler:plugin-api"))
implementation(project(":compiler:backend.jvm.entrypoint"))
compileOnly(toolsJarApi()) compileOnly(toolsJarApi())
compileOnly(project(":kotlin-annotation-processing-cli")) compileOnly(project(":kotlin-annotation-processing-cli"))
@@ -24,23 +24,27 @@ import com.sun.tools.javac.tree.TreeMaker
import com.sun.tools.javac.util.Context import com.sun.tools.javac.util.Context
import org.jetbrains.kotlin.analyzer.AnalysisResult import org.jetbrains.kotlin.analyzer.AnalysisResult
import org.jetbrains.kotlin.backend.common.output.OutputFile import org.jetbrains.kotlin.backend.common.output.OutputFile
import org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory
import org.jetbrains.kotlin.base.kapt3.AptMode.APT_ONLY import org.jetbrains.kotlin.base.kapt3.AptMode.APT_ONLY
import org.jetbrains.kotlin.base.kapt3.AptMode.WITH_COMPILATION import org.jetbrains.kotlin.base.kapt3.AptMode.WITH_COMPILATION
import org.jetbrains.kotlin.base.kapt3.DetectMemoryLeaksMode import org.jetbrains.kotlin.base.kapt3.DetectMemoryLeaksMode
import org.jetbrains.kotlin.base.kapt3.KaptFlag import org.jetbrains.kotlin.base.kapt3.KaptFlag
import org.jetbrains.kotlin.base.kapt3.KaptOptions import org.jetbrains.kotlin.base.kapt3.KaptOptions
import org.jetbrains.kotlin.base.kapt3.collectJavaSourceFiles import org.jetbrains.kotlin.base.kapt3.collectJavaSourceFiles
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.OUTPUT import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.OUTPUT
import org.jetbrains.kotlin.cli.common.messages.MessageCollector import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.cli.common.messages.OutputMessageUtil import org.jetbrains.kotlin.cli.common.messages.OutputMessageUtil
import org.jetbrains.kotlin.cli.common.output.writeAll import org.jetbrains.kotlin.cli.common.output.writeAll
import org.jetbrains.kotlin.cli.jvm.plugins.ServiceLoaderLite import org.jetbrains.kotlin.cli.jvm.plugins.ServiceLoaderLite
import org.jetbrains.kotlin.codegen.ClassBuilderMode import org.jetbrains.kotlin.codegen.ClassBuilderMode
import org.jetbrains.kotlin.codegen.DefaultCodegenFactory
import org.jetbrains.kotlin.codegen.KotlinCodegenFacade import org.jetbrains.kotlin.codegen.KotlinCodegenFacade
import org.jetbrains.kotlin.codegen.OriginCollectingClassBuilderFactory import org.jetbrains.kotlin.codegen.OriginCollectingClassBuilderFactory
import org.jetbrains.kotlin.codegen.state.GenerationState import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.config.CommonConfigurationKeys import org.jetbrains.kotlin.config.CommonConfigurationKeys
import org.jetbrains.kotlin.config.CompilerConfiguration import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.JVMConfigurationKeys
import org.jetbrains.kotlin.container.ComponentProvider import org.jetbrains.kotlin.container.ComponentProvider
import org.jetbrains.kotlin.context.ProjectContext import org.jetbrains.kotlin.context.ProjectContext
import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.descriptors.ModuleDescriptor
@@ -263,6 +267,7 @@ abstract class AbstractKapt3Extension(
type = "java-production" type = "java-production"
) )
val isIrBackend = compilerConfiguration.getBoolean(JVMConfigurationKeys.USE_KAPT_WITH_JVM_IR)
val generationState = GenerationState.Builder( val generationState = GenerationState.Builder(
project, project,
builderFactory, builderFactory,
@@ -271,7 +276,12 @@ abstract class AbstractKapt3Extension(
files, files,
compilerConfiguration compilerConfiguration
).targetId(targetId) ).targetId(targetId)
.isIrBackend(false) .isIrBackend(isIrBackend)
.codegenFactory(
if (isIrBackend)
JvmIrCodegenFactory(compilerConfiguration, compilerConfiguration.get(CLIConfigurationKeys.PHASE_CONFIG))
else DefaultCodegenFactory
)
.build() .build()
val (classFilesCompilationTime) = measureTimeMillis { val (classFilesCompilationTime) = measureTimeMillis {
@@ -7,10 +7,6 @@ package org.jetbrains.kotlin.kapt3.test
import org.jetbrains.kotlin.test.TargetBackend import org.jetbrains.kotlin.test.TargetBackend
/*
Currently Kapt3 only works with the old backend. To enable IR, modify the isIrBackend variable computation in GenerationsUtils.compileFiles()
*/
abstract class AbstractIrClassFileToSourceStubConverterTest : AbstractClassFileToSourceStubConverterTest() { abstract class AbstractIrClassFileToSourceStubConverterTest : AbstractClassFileToSourceStubConverterTest() {
override val backend = TargetBackend.JVM_IR override val backend = TargetBackend.JVM_IR
} }
@@ -37,6 +37,8 @@ import org.jetbrains.kotlin.codegen.ClassBuilderMode
import org.jetbrains.kotlin.codegen.CodegenTestFiles import org.jetbrains.kotlin.codegen.CodegenTestFiles
import org.jetbrains.kotlin.codegen.GenerationUtils import org.jetbrains.kotlin.codegen.GenerationUtils
import org.jetbrains.kotlin.codegen.OriginCollectingClassBuilderFactory import org.jetbrains.kotlin.codegen.OriginCollectingClassBuilderFactory
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.JVMConfigurationKeys
import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor
import org.jetbrains.kotlin.kapt.base.test.JavaKaptContextTest import org.jetbrains.kotlin.kapt.base.test.JavaKaptContextTest
import org.jetbrains.kotlin.kapt3.Kapt3ComponentRegistrar.KaptComponentContributor import org.jetbrains.kotlin.kapt3.Kapt3ComponentRegistrar.KaptComponentContributor
@@ -55,7 +57,6 @@ import org.jetbrains.kotlin.resolve.jvm.extensions.PartialAnalysisHandlerExtensi
import org.jetbrains.kotlin.test.ConfigurationKind import org.jetbrains.kotlin.test.ConfigurationKind
import org.jetbrains.kotlin.test.KotlinTestUtils import org.jetbrains.kotlin.test.KotlinTestUtils
import org.jetbrains.kotlin.test.TestJdkKind import org.jetbrains.kotlin.test.TestJdkKind
import org.jetbrains.kotlin.test.util.KtTestUtil
import org.jetbrains.kotlin.test.util.trimTrailingWhitespacesAndAddNewlineAtEOF import org.jetbrains.kotlin.test.util.trimTrailingWhitespacesAndAddNewlineAtEOF
import org.jetbrains.kotlin.utils.PathUtil import org.jetbrains.kotlin.utils.PathUtil
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance
@@ -172,6 +173,14 @@ abstract class AbstractKotlinKapt3Test : KotlinKapt3TestBase() {
} }
} }
override fun updateConfiguration(configuration: CompilerConfiguration) {
super.updateConfiguration(configuration)
if (backend.isIR) {
configuration.put(JVMConfigurationKeys.USE_KAPT_WITH_JVM_IR, true)
}
}
protected fun convert( protected fun convert(
kaptContext: KaptContextForStubGeneration, kaptContext: KaptContextForStubGeneration,
javaFiles: List<File>, javaFiles: List<File>,
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
enum class E { enum class E {
X { X {
override fun a() {} override fun a() {}
@@ -34,4 +36,4 @@ enum class E3(val a: String) {
enum class E4(val a: String, val b: Int, val c: Long, val d: Boolean) { enum class E4(val a: String, val b: Int, val c: Long, val d: Boolean) {
X("", 4, 2L, true) X("", 4, 2L, true)
} }
@@ -6,4 +6,4 @@ abstract class Base {
class Impl : Base() { class Impl : Base() {
override fun doJob(job: String, delay: Int) {} override fun doJob(job: String, delay: Int) {}
override fun <T : CharSequence> doJobGeneric(job: T, delay: Int) {} override fun <T : CharSequence> doJobGeneric(job: T, delay: Int) {}
} }
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// CORRECT_ERROR_TYPES // CORRECT_ERROR_TYPES
// NO_VALIDATION // NO_VALIDATION
@@ -25,4 +26,4 @@ class Test {
class Test2 { class Test2 {
lateinit var date: MyDate lateinit var date: MyDate
} }
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// CORRECT_ERROR_TYPES // CORRECT_ERROR_TYPES
// NO_VALIDATION // NO_VALIDATION
@@ -29,4 +30,4 @@ class Foo
class Bar class Bar
@Anno(impls = [Joo::class]) @Anno(impls = [Joo::class])
class Boo class Boo
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
annotation class Anno1 annotation class Anno1
enum class Colors { WHITE, BLACK } enum class Colors { WHITE, BLACK }
annotation class Anno2( annotation class Anno2(
@@ -32,4 +34,4 @@ class TestAnno2 {
enum class Enum1 { enum class Enum1 {
BLACK, @Anno1 WHITE BLACK, @Anno1 WHITE
} }
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
@file:kotlin.jvm.JvmName("AnnotationsTest") @file:kotlin.jvm.JvmName("AnnotationsTest")
package test package test
@@ -29,4 +31,4 @@ val @receiver:Anno("top-level-val-receiver") Int.topLevelVal: String
@Anno("enum") @Anno("enum")
enum class Enum @Anno("enum-constructor") constructor(@Anno("x") val x: Int) { enum class Enum @Anno("enum-constructor") constructor(@Anno("x") val x: Int) {
@Anno("white") WHITE(1), @Anno("black") BLACK(2) @Anno("white") WHITE(1), @Anno("black") BLACK(2)
} }
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// WITH_STDLIB // WITH_STDLIB
interface Parceler<T> interface Parceler<T>
@@ -15,4 +16,4 @@ class B
class C class C
object BParceler : Parceler<B> object BParceler : Parceler<B>
object CParceler : Parceler<C> object CParceler : Parceler<C>
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
//FILE: lib/R.java //FILE: lib/R.java
package lib; package lib;
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
@Target(AnnotationTarget.FIELD) @Target(AnnotationTarget.FIELD)
annotation class FieldAnno annotation class FieldAnno
@@ -20,4 +22,4 @@ class Baz {
@FieldAnno @Anno @FieldAnno @Anno
@JvmField @JvmField
val a: String = "" val a: String = ""
} }
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// CORRECT_ERROR_TYPES // CORRECT_ERROR_TYPES
import kotlin.reflect.KProperty import kotlin.reflect.KProperty
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
/** Test. */ /** Test. */
class Test { class Test {
@@ -64,4 +65,4 @@ enum class EnumError {
/** /**
* `/* Failure */` * `/* Failure */`
*/ */
interface TestComponent interface TestComponent
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// !KEEP_KDOC_COMMENTS_IN_STUBS // !KEEP_KDOC_COMMENTS_IN_STUBS
/** Test. */ /** Test. */
class Test { class Test {
@@ -64,4 +65,4 @@ enum class EnumError {
/** /**
* `/* Failure */` * `/* Failure */`
*/ */
interface TestComponent interface TestComponent
@@ -1,2 +1,2 @@
class Привет class Привет
class République class République
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
data class User(val firstName: String, val secondName: String, val age: Int) { data class User(val firstName: String, val secondName: String, val age: Int) {
fun procedure() {} fun procedure() {}
} }
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
interface IntfWithoutDefaultImpls interface IntfWithoutDefaultImpls
interface IntfWithDefaultImpls { interface IntfWithDefaultImpls {
@@ -12,4 +14,4 @@ interface Intf {
val color: Int val color: Int
get() = BLACK get() = BLACK
} }
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// STRICT // STRICT
//FILE: test/ClassRefAnnotation.java //FILE: test/ClassRefAnnotation.java
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// CORRECT_ERROR_TYPES // CORRECT_ERROR_TYPES
// STRICT // STRICT
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
class Foo( class Foo(
val z: Boolean = true, val z: Boolean = true,
val b: Byte = 0.toByte(), val b: Byte = 0.toByte(),
@@ -26,4 +28,4 @@ class Foo(
enum class Em { enum class Em {
FOO, BAR FOO, BAR
} }
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// DUMP_DEFAULT_PARAMETER_VALUES // DUMP_DEFAULT_PARAMETER_VALUES
class Foo( class Foo(
@@ -25,4 +26,4 @@ class Foo(
enum class Em { enum class Em {
FOO, BAR FOO, BAR
} }
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// CORRECT_ERROR_TYPES // CORRECT_ERROR_TYPES
@file:Suppress("UNRESOLVED_REFERENCE") @file:Suppress("UNRESOLVED_REFERENCE")
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
package deprecated package deprecated
@Deprecated("Deprecated annotation") @Deprecated("Deprecated annotation")
@@ -15,4 +17,4 @@ class Foo {
var foo: Int var foo: Int
@Deprecated("Deprecated getter") get() = 0 @Deprecated("Deprecated getter") get() = 0
@Deprecated("Deprecated setter") set(value) {} @Deprecated("Deprecated setter") set(value) {}
} }
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// CORRECT_ERROR_TYPES // CORRECT_ERROR_TYPES
package kapt package kapt
@@ -9,4 +10,4 @@ import kotlin.annotation.Repeatable
enum class Options { enum class Options {
A, B, C A, B, C
} }
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
class Test { class Test {
private val foo = Example.FOO private val foo = Example.FOO
@@ -42,4 +44,4 @@ class Test5 {
} }
} }
} }
} }
+3 -1
View File
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
enum class Enum1 { enum class Enum1 {
BLACK, WHITE BLACK, WHITE
} }
@@ -20,4 +22,4 @@ enum class Nested1 {
} }
} }
}; };
} }
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// CORRECT_ERROR_TYPES // CORRECT_ERROR_TYPES
@file:Suppress("UNRESOLVED_REFERENCE", "ANNOTATION_ARGUMENT_MUST_BE_CONST", "NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION") @file:Suppress("UNRESOLVED_REFERENCE", "ANNOTATION_ARGUMENT_MUST_BE_CONST", "NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION")
@@ -27,6 +28,6 @@ class ErrorInDeclarations {
annotation class Anno(val a: KClass<Any>) annotation class Anno(val a: KClass<Any>)
// EXPECTED_ERROR(kotlin:11:1) cannot find symbol
// EXPECTED_ERROR(kotlin:6:1) cannot find symbol
// EXPECTED_ERROR(kotlin:12:1) cannot find symbol // EXPECTED_ERROR(kotlin:12:1) cannot find symbol
// EXPECTED_ERROR(kotlin:7:1) cannot find symbol
// EXPECTED_ERROR(kotlin:13:1) cannot find symbol
@@ -1,7 +1,9 @@
// IGNORE_BACKEND: JVM_IR
package test package test
internal annotation class Anno internal annotation class Anno
@Anno @Anno
@Suppress("UNRESOLVED_REFERENCE") @Suppress("UNRESOLVED_REFERENCE")
internal class ClassWithParent: Foo(), Bar, Baz, CharSequence internal class ClassWithParent: Foo(), Bar, Baz, CharSequence
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// CORRECT_ERROR_TYPES // CORRECT_ERROR_TYPES
// NO_VALIDATION // NO_VALIDATION
// WITH_STDLIB // WITH_STDLIB
@@ -52,4 +53,4 @@ class MappedList<R>() : AbstractList<R>(), List<R> {
interface Parent<A : CharSequence?, B> interface Parent<A : CharSequence?, B>
class Child : AbstractList<String>(), Parent<String, Int>, List<String> class Child : AbstractList<String>(), Parent<String, Int>, List<String>
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// WITH_STDLIB // WITH_STDLIB
@file:JvmName("FacadeName") @file:JvmName("FacadeName")
@@ -5,4 +6,4 @@ package a.b.c
fun foo() {} fun foo() {}
const val bar = 3 const val bar = 3
@@ -3,4 +3,4 @@ class FunctionsTest {
fun f2() = fun (a: Int, b: Int) = a > b fun f2() = fun (a: Int, b: Int) = a > b
fun f3() = run {} fun f3() = run {}
fun f4() = run { 3 } fun f4() = run { 3 }
} }
@@ -1,7 +1,8 @@
// IGNORE_BACKEND: JVM_IR
// CORRECT_ERROR_TYPES // CORRECT_ERROR_TYPES
// WITH_STDLIB // WITH_STDLIB
class MappedList<out T, R>(val list: List<T>, private val function: (T) -> R) : AbstractList<R>(), List<R> { class MappedList<out T, R>(val list: List<T>, private val function: (T) -> R) : AbstractList<R>(), List<R> {
override fun get(index: Int) = function(list[index]) override fun get(index: Int) = function(list[index])
override val size get() = list.size override val size get() = list.size
} }
@@ -1,4 +1,6 @@
// IGNORE_BACKEND: JVM_IR
class GenericRawSignatures { class GenericRawSignatures {
fun <T> genericFun(): T? = null fun <T> genericFun(): T? = null
fun nonGenericFun(): String? = null fun nonGenericFun(): String? = null
} }
@@ -12,4 +12,4 @@ class MyClass<M1, M2> : Intf<Any, java.util.Date>, OtherIntf<String>, BaseClass<
interface ABC { interface ABC {
fun <T : CharSequence> abc(item: T, items: List<T>, vararg otherItems: T): List<T> fun <T : CharSequence> abc(item: T, items: List<T>, vararg otherItems: T): List<T>
fun <X> bcd(vararg a: Char): Int fun <X> bcd(vararg a: Char): Int
} }
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
import kotlinx.kapt.* import kotlinx.kapt.*
class Test { class Test {
@@ -10,4 +12,4 @@ class Test {
fun nonIgnoredFun() {} fun nonIgnoredFun() {}
val nonIgnoredProperty: String = "" val nonIgnoredProperty: String = ""
} }
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// WITH_STDLIB // WITH_STDLIB
// FILE: lib/Prop.java // FILE: lib/Prop.java
@@ -34,4 +35,4 @@ val TESTS_LIST = listOf(object : Prop<Cl>() {
override fun set(key: Cl, value: Int) { override fun set(key: Cl, value: Int) {
key.name = " ".repeat(value) key.name = " ".repeat(value)
} }
}) })
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// CORRECT_ERROR_TYPES // CORRECT_ERROR_TYPES
import java.util.concurrent.* import java.util.concurrent.*
@@ -9,4 +10,4 @@ import java.util.Calendar.*
fun test(): Any? { fun test(): Any? {
return null return null
} }
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// CORRECT_ERROR_TYPES // CORRECT_ERROR_TYPES
// FILE: a.kt // FILE: a.kt
@@ -52,4 +53,4 @@ interface TestC {
fun e(): LibFooBar fun e(): LibFooBar
} }
// EXPECTED_ERROR(kotlin:17:5) cannot find symbol // EXPECTED_ERROR(kotlin:17:5) cannot find symbol
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
class HomeFragment { class HomeFragment {
@Suppress("TOO_MANY_ARGUMENTS", "DELEGATE_SPECIAL_FUNCTION_MISSING") @Suppress("TOO_MANY_ARGUMENTS", "DELEGATE_SPECIAL_FUNCTION_MISSING")
private val categoryNewsListPresenter by moxyPresenter { private val categoryNewsListPresenter by moxyPresenter {
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
interface Context interface Context
enum class Result { enum class Result {
@@ -10,4 +12,4 @@ abstract class BaseClass(context: Context, num: Int, bool: Boolean) {
class Inheritor(context: Context) : BaseClass(context, 5, true) { class Inheritor(context: Context) : BaseClass(context, 5, true) {
override fun doJob() = Result.SUCCESS override fun doJob() = Result.SUCCESS
} }
@@ -1 +1,3 @@
inline class Cl(val a: String) // IGNORE_BACKEND: JVM_IR
inline class Cl(val a: String)
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
class Test { class Test {
private var a = FilterValueDelegate<Float>() private var a = FilterValueDelegate<Float>()
private inner class FilterValueDelegate<T> private inner class FilterValueDelegate<T>
@@ -13,4 +15,4 @@ class Test2 {
class Test3 { class Test3 {
private var a = FilterValueDelegate<Float>() private var a = FilterValueDelegate<Float>()
private class FilterValueDelegate<T> private class FilterValueDelegate<T>
} }
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
interface Named { interface Named {
val name: String? val name: String?
} }
@@ -8,4 +10,4 @@ class Product2 : Named {
constructor(otherName: String) { constructor(otherName: String) {
this.name = otherName this.name = otherName
} }
} }
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
enum class Color { enum class Color {
BLACK, `WHI-TE` BLACK, `WHI-TE`
} }
@@ -5,5 +7,5 @@ enum class Color {
@Anno(Color.`WHI-TE`) @Anno(Color.`WHI-TE`)
annotation class Anno(val color: Color) annotation class Anno(val color: Color)
// EXPECTED_ERROR(kotlin:5:1) an enum annotation value must be an enum constant // EXPECTED_ERROR(kotlin:7:1) an enum annotation value must be an enum constant
// EXPECTED_ERROR(other:-1:-1) 'WHI-TE' is an invalid Java enum value name // EXPECTED_ERROR(other:-1:-1) 'WHI-TE' is an invalid Java enum value name
@@ -1,4 +1,4 @@
class default { class default {
lateinit val extends: String lateinit val extends: String
fun implements(instanceof: Int) {} fun implements(instanceof: Int) {}
} }
@@ -16,4 +16,4 @@ class D
// FILE: e.kt // FILE: e.kt
package a.b.`typealias`.c package a.b.`typealias`.c
class E class E
+3 -1
View File
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
package javadoc package javadoc
/** Simple */ /** Simple */
@@ -32,4 +34,4 @@ class B {
stars stars
*/ */
val d = "" val d = ""
} }
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// !JVM_DEFAULT_MODE: all // !JVM_DEFAULT_MODE: all
interface Foo { interface Foo {
@@ -10,4 +11,4 @@ interface Foo {
} }
fun bar() fun bar()
} }
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// !JVM_DEFAULT_MODE: all-compatibility // !JVM_DEFAULT_MODE: all-compatibility
interface Foo { interface Foo {
@@ -10,4 +11,4 @@ interface Foo {
} }
fun bar() fun bar()
} }
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// !JVM_DEFAULT_MODE: disable // !JVM_DEFAULT_MODE: disable
interface Foo { interface Foo {
@@ -11,4 +12,4 @@ interface Foo {
} }
fun bar() fun bar()
} }
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// !JVM_DEFAULT_MODE: enable // !JVM_DEFAULT_MODE: enable
interface Foo { interface Foo {
@@ -11,4 +12,4 @@ interface Foo {
} }
fun bar() fun bar()
} }
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
class State @JvmOverloads constructor( class State @JvmOverloads constructor(
val someInt: Int, val someInt: Int,
val someLong: Long, val someLong: Long,
@@ -14,4 +16,4 @@ class State2 @JvmOverloads constructor(
fun someMethod(str: String) {} fun someMethod(str: String) {}
fun methodWithoutArgs() {} fun methodWithoutArgs() {}
} }
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
class JvmStaticTest { class JvmStaticTest {
companion object { companion object {
@JvmStatic @JvmStatic
@@ -17,4 +19,4 @@ interface FooComponent {
@JvmStatic @JvmStatic
fun create(context: String): String = "foo" fun create(context: String): String = "foo"
} }
} }
@@ -1,6 +1,8 @@
// IGNORE_BACKEND: JVM_IR
class Test { class Test {
companion object A { companion object A {
@JvmStatic @JvmStatic
val test: String = "" val test: String = ""
} }
} }
+3 -1
View File
@@ -1,7 +1,9 @@
// IGNORE_BACKEND: JVM_IR
fun crashMe(values: List<String>): String { fun crashMe(values: List<String>): String {
throw UnsupportedOperationException() throw UnsupportedOperationException()
} }
fun crashMe(values: List<CharSequence>): CharSequence { fun crashMe(values: List<CharSequence>): CharSequence {
throw UnsupportedOperationException() throw UnsupportedOperationException()
} }
+2 -1
View File
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// WITH_STDLIB // WITH_STDLIB
@file:Suppress("AMBIGUOUS_ANONYMOUS_TYPE_INFERRED") @file:Suppress("AMBIGUOUS_ANONYMOUS_TYPE_INFERRED")
@@ -32,4 +33,4 @@ fun e() = arrayOf(object : Runnable {
fun e1(a: Array<CharSequence>) {} fun e1(a: Array<CharSequence>) {}
fun e2(a: Array<in CharSequence>) {} fun e2(a: Array<in CharSequence>) {}
fun e3(a: Array<out CharSequence>) {} fun e3(a: Array<out CharSequence>) {}
fun e3(a: Array<*>) {} fun e3(a: Array<*>) {}
+1 -1
View File
@@ -7,4 +7,4 @@ class Outer {
} }
abstract fun abstract(s: String, i: Int) abstract fun abstract(s: String, i: Int)
} }
+1 -1
View File
@@ -1,4 +1,4 @@
interface MyInterface { interface MyInterface {
fun someFun() fun someFun()
private class MyDefaultInferface() private class MyDefaultInferface()
} }
+3 -1
View File
@@ -1,6 +1,8 @@
// IGNORE_BACKEND: JVM_IR
package test package test
internal class MutableEntry<K, V>( internal class MutableEntry<K, V>(
private val internal: MutableMap<K, V>, private val internal: MutableMap<K, V>,
override val key: K, value: V override val key: K, value: V
): MutableMap.MutableEntry<K, V> ): MutableMap.MutableEntry<K, V>
+3 -1
View File
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
import java.util.Date import java.util.Date
fun Date(double: Double): Date = Date(double.times(1000).toLong()) fun Date(double: Double): Date = Date(double.times(1000).toLong())
+1 -1
View File
@@ -22,4 +22,4 @@ fun test4() = (0..10).map { n ->
object : Foo(), Runnable { object : Foo(), Runnable {
override fun run() {} override fun run() {}
} }
} }
+3 -1
View File
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
package test package test
class Test<T : CharSequence, N : Number> { class Test<T : CharSequence, N : Number> {
@@ -8,4 +10,4 @@ class Test<T : CharSequence, N : Number> {
interface ListUpdateCallback { interface ListUpdateCallback {
fun onInserted(position: Int, count: Int) fun onInserted(position: Int, count: Int)
} }
+3 -1
View File
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
package test package test
class Test<T : CharSequence, N : Number> { class Test<T : CharSequence, N : Number> {
@@ -8,4 +10,4 @@ class Test<T : CharSequence, N : Number> {
interface TypedListUpdateCallback<T : Any, C : Number> { interface TypedListUpdateCallback<T : Any, C : Number> {
fun onInserted(position: C, count: C, item: T) fun onInserted(position: C, count: C, item: T)
} }
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// STRICT // STRICT
class Foo(private val string: String) { class Foo(private val string: String) {
+2 -1
View File
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// CORRECT_ERROR_TYPES // CORRECT_ERROR_TYPES
// FILE: kapt/StaticMethod.java // FILE: kapt/StaticMethod.java
@@ -40,4 +41,4 @@ class StaticImport {
val l = of("hello", "world") val l = of("hello", "world")
val m = of2("hello") val m = of2("hello")
val y = "1".func() val y = "1".func()
} }
+2 -1
View File
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// WITH_STDLIB // WITH_STDLIB
@file:Suppress("NOTHING_TO_INLINE") @file:Suppress("NOTHING_TO_INLINE")
@@ -37,4 +38,4 @@ abstract class BundleProperty<AA>(key: String?) : NullableBundleProperty<AA>(key
} }
abstract fun setValue(bundle: Any, key: String, value: AA) abstract fun setValue(bundle: Any, key: String, value: AA)
} }
+2 -1
View File
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// CORRECT_ERROR_TYPES // CORRECT_ERROR_TYPES
package foo package foo
@@ -6,4 +7,4 @@ interface InterfaceWithDefaults<T> {
fun foo() {} fun foo() {}
} }
interface SubInterface<T> : InterfaceWithDefaults<T> interface SubInterface<T> : InterfaceWithDefaults<T>
+4 -3
View File
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// CORRECT_ERROR_TYPES // CORRECT_ERROR_TYPES
@file:Suppress("UNRESOLVED_REFERENCE", "ANNOTATION_ARGUMENT_MUST_BE_CONST") @file:Suppress("UNRESOLVED_REFERENCE", "ANNOTATION_ARGUMENT_MUST_BE_CONST")
@@ -14,6 +15,6 @@ class ErrorSomeMissingAnnotations
annotation class Anno(val klass: KClass<*>) annotation class Anno(val klass: KClass<*>)
// EXPECTED_ERROR(kotlin:12:1) cannot find symbol // EXPECTED_ERROR(kotlin:10:1) cannot find symbol
// EXPECTED_ERROR(kotlin:6:1) cannot find symbol // EXPECTED_ERROR(kotlin:13:1) cannot find symbol
// EXPECTED_ERROR(kotlin:9:1) cannot find symbol // EXPECTED_ERROR(kotlin:7:1) cannot find symbol
+3 -1
View File
@@ -1,4 +1,6 @@
// IGNORE_BACKEND: JVM_IR
class T : Runnable { class T : Runnable {
@Override @Override
public override fun run() {} public override fun run() {}
} }
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// WITH_STDLIB // WITH_STDLIB
interface Intf interface Intf
@@ -16,4 +16,4 @@ package test
fun test(a: `$Test`.`$Inner`) {} fun test(a: `$Test`.`$Inner`) {}
fun test(a: `Test$`.`Inner$`) {} fun test(a: `Test$`.`Inner$`) {}
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// CORRECT_ERROR_TYPES // CORRECT_ERROR_TYPES
// FILE: te/st/a/JavaClass // FILE: te/st/a/JavaClass
@@ -13,4 +14,4 @@ import te.st.a.`$Test`.Inner as MyInner
import te.st.a.`Test$`.Inner as MyInner2 import te.st.a.`Test$`.Inner as MyInner2
import te.st.a.`Test$`.`Inner$` as MyInner3 import te.st.a.`Test$`.`Inner$` as MyInner3
fun a(a: MyInner) {} fun a(a: MyInner) {}
@@ -1,4 +1,4 @@
interface EntryHolder { interface EntryHolder {
fun entry(p: Map.Entry<CharSequence, Map.Entry<String, Int>>): Map.Entry<String, Any> fun entry(p: Map.Entry<CharSequence, Map.Entry<String, Int>>): Map.Entry<String, Any>
val entryProperty: Map.Entry<String, Any> val entryProperty: Map.Entry<String, Any>
} }
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// CORRECT_ERROR_TYPES // CORRECT_ERROR_TYPES
// JAVAC_OPTION -Xmaxerrs=1 // JAVAC_OPTION -Xmaxerrs=1
@@ -11,4 +12,4 @@ class Test {
// There are two errors (unresolved identifier ABC, BCD) actually. // There are two errors (unresolved identifier ABC, BCD) actually.
// But we specified the max error count, so the error output is limited. // But we specified the max error count, so the error output is limited.
// EXPECTED_ERROR(kotlin:8:5) cannot find symbol // EXPECTED_ERROR(kotlin:8:5) cannot find symbol
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
interface Intf { interface Intf {
fun foo(abc: String) fun foo(abc: String)
@@ -12,4 +14,4 @@ abstract class Cls {
fun bar(bcd: Int): String { fun bar(bcd: Int): String {
return "" return ""
} }
} }
@@ -1,7 +1,9 @@
// IGNORE_BACKEND: JVM_IR
class CrashMe { class CrashMe {
val resources = 1 val resources = 1
fun getResources(): String { fun getResources(): String {
return "" return ""
} }
} }
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
package modifiers package modifiers
public class PublicClass public constructor() public class PublicClass public constructor()
@@ -34,4 +36,4 @@ class Modifiers {
@JvmOverloads @JvmOverloads
fun overloads(a: String = "", n: Int = 5): String = null!! fun overloads(a: String = "", n: Int = 5): String = null!!
} }
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// WITH_STDLIB // WITH_STDLIB
// FILE: a.kt // FILE: a.kt
@@ -19,4 +20,4 @@ fun bar() {}
@file:JvmName("M2") @file:JvmName("M2")
package test package test
fun baz() {} fun baz() {}
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
class Test { class Test {
class Nested { class Nested {
class NestedNested class NestedNested
@@ -55,4 +57,4 @@ class A2 {
} }
} }
} }
} }
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// FILE: JavaClass.java // FILE: JavaClass.java
public class JavaClass { public class JavaClass {
public class Foo { public class Foo {
@@ -78,4 +79,4 @@ class Test1(val zoo: Foo.Bar.Zoo) : Foo.Bar(), IFoo.IBar, IFoo.IBar.IZoo {
} }
// EXPECTED_ERROR class J$B is public, should be declared in a file named J$B.java // 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 // EXPECTED_ERROR class JavaClass is public, should be declared in a file named JavaClass.java
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// FILE: test/JavaClass.java // FILE: test/JavaClass.java
package test; package test;
@@ -83,4 +84,4 @@ class Test1(val zoo: Foo.Bar.Zoo) : Foo.Bar(), IFoo.IBar, IFoo.IBar.IZoo {
fun b(foo: JavaClass.Foo, bar: JavaClass.Foo.Bar) {} fun b(foo: JavaClass.Foo, bar: JavaClass.Foo.Bar) {}
} }
// EXPECTED_ERROR class J$B is public, should be declared in a file named J$B.java // EXPECTED_ERROR class J$B is public, should be declared in a file named J$B.java
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// CORRECT_ERROR_TYPES // CORRECT_ERROR_TYPES
// NON_EXISTENT_CLASS // NON_EXISTENT_CLASS
// NO_VALIDATION // NO_VALIDATION
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// CORRECT_ERROR_TYPES // CORRECT_ERROR_TYPES
// NON_EXISTENT_CLASS // NON_EXISTENT_CLASS
// NO_VALIDATION // NO_VALIDATION
@@ -63,4 +64,4 @@ class Test<G> {
class MyType<T> class MyType<T>
annotation class Anno(val a: KClass<*>, val b: Array<KClass<*>>, val c: Array<KClass<*>>, vararg val d: KClass<*>) annotation class Anno(val a: KClass<*>, val b: Array<KClass<*>>, val c: Array<KClass<*>>, vararg val d: KClass<*>)
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// NON_EXISTENT_CLASS // NON_EXISTENT_CLASS
// NO_VALIDATION // NO_VALIDATION
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
object PrimitiveTypes { object PrimitiveTypes {
const val booleanFalse: Boolean = false const val booleanFalse: Boolean = false
const val booleanTrue: Boolean = true const val booleanTrue: Boolean = true
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
class Test { class Test {
val simple: String = "123" val simple: String = "123"
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
annotation class Anno annotation class Anno
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.CLASS) @Target(AnnotationTarget.PROPERTY, AnnotationTarget.CLASS)
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// FILE: androidx/annotation/RecentlyNullable.java // FILE: androidx/annotation/RecentlyNullable.java
package androidx.annotation; package androidx.annotation;
@@ -20,4 +21,4 @@ package app
import androidx.annotation.Box import androidx.annotation.Box
class KBox(val delegate: Box) : Box by delegate class KBox(val delegate: Box) : Box by delegate
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// FILE: lib/Anno.java // FILE: lib/Anno.java
package lib; package lib;
public @interface Anno { public @interface Anno {
@@ -55,4 +56,4 @@ annotation class AnnoEnum(val x: Int, val c: Color)
@AnnoLongArray(lib.R.id.textView, [1L, 3L]) @AnnoLongArray(lib.R.id.textView, [1L, 3L])
@AnnoArray(lib.R.id.textView, [ "A", "B" ]) @AnnoArray(lib.R.id.textView, [ "A", "B" ])
@AnnoClass(lib.R.id.textView, Color::class) @AnnoClass(lib.R.id.textView, Color::class)
class Test2 class Test2
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// CORRECT_ERROR_TYPES // CORRECT_ERROR_TYPES
package secondary package secondary
@@ -12,4 +13,4 @@ class Product2 : Named {
constructor(otherName: String) { constructor(otherName: String) {
this.name = otherName this.name = otherName
} }
} }
@@ -6,4 +6,4 @@ fun foo() {}
// FILE: b.kt // FILE: b.kt
package test package test
fun bar() {} fun bar() {}
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
class `:)` { class `:)` {
lateinit val f: String lateinit val f: String
} }
@@ -37,4 +39,4 @@ class `A B` {
class C class C
} }
// EXPECTED_ERROR(other:-1:-1) '60x60' is an invalid Java enum value name // EXPECTED_ERROR(other:-1:-1) '60x60' is an invalid Java enum value name
@@ -9,4 +9,4 @@ class `My $ name` {
// japanese hiragana // japanese hiragana
fun `こ と り ん!`() {} fun `こ と り ん!`() {}
} }
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// STRIP_METADATA // STRIP_METADATA
interface Context interface Context
@@ -12,4 +13,4 @@ abstract class BaseClass(context: Context, num: Int, bool: Boolean) {
class Inheritor(context: Context) : BaseClass(context, 5, true) { class Inheritor(context: Context) : BaseClass(context, 5, true) {
override fun doJob() = Result.SUCCESS override fun doJob() = Result.SUCCESS
} }
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
open class Test { open class Test {
open fun getTestNoSuspend(text: String): String { open fun getTestNoSuspend(text: String): String {
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// CORRECT_ERROR_TYPES // CORRECT_ERROR_TYPES
// NO_VALIDATION // NO_VALIDATION
// WITH_STDLIB // WITH_STDLIB
@@ -7,4 +8,4 @@ class Foo {
suspend fun a(): ABC = TODO() suspend fun a(): ABC = TODO()
suspend fun b(): Result<ABC> = TODO() suspend fun b(): Result<ABC> = TODO()
} }

Some files were not shown because too many files have changed in this diff Show More